Click here to Skip to main content
15,879,613 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi experts, i wanna ask you about threading..
Can we make some thread by customise the thread, I mean that I can make some thread by set the number of thread in xml for example, so my app can generate some thread by reading the number of threading in this xml. Give me the example please... :(

Your question is poorly phrased, so I'm not exactly sure what you're talking about. Yes, you can read in an integer from an XML file then create that many threads. What problem are you having specifically? Do you not know how to create a thread? How to read an XML file? How to use a for loop? If you know how to do all those things, then you should be able to accomplish this task.
Share this answer
Teamsar Muliadi 23-Sep-10 23:55pm    
Sorry.. if my english is so bad... so you can't exactly sure what i mean.. :(

Yes.. i know how to make a thrad, read an xml file, and use a for loop. But, how to implement this problem.. i'm really2 blank.. what is the main point to start first.. may you help me to give me an example please.. ?? :(
AspDotNetDev 23-Sep-10 23:56pm    
I reckon you should start by reading the XML file.
Teamsar Muliadi 24-Sep-10 0:43am    
using System.Xml;
* sample of xml :
* <record name="TotalThread">
* <field name="total">5

private int GET_NUMBER_OF_THREAD()
int total_thread = 0;
XmlTextReader obj = new XmlTextReader();

string flag = obj.GetAttribute("name");
if(flag == "total")
total_thread = obj.Value;

return total_thread;

Next step...??
AspDotNetDev 24-Sep-10 1:11am    
For loop.

Since you know how to accomplish all the single tasks here is some Pseudo code for you that may give you an idea how to implement your problem:

int nThreadCount = ReadXMLInteger(); //read an integer number from your xml file
for(int i = 0; i < nThreadCount; i++)
Share this answer
Teamsar Muliadi 24-Sep-10 0:49am    
ok.. you have just made some thread.. But, how do you implement these threads if you have some message to be processed by these threads ??? :confuse:
JF2015 24-Sep-10 0:51am    
You could easily call the thread with a parameter. This parameter could be the ThreadNumber or another value that you have read from the xml file.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900