Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Joining a thread
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
01049204
Message ID:
01049248
Vues:
14
Chad,
It is acctually very simple, I only start one thread at the time and I join the thread after a relatively short period of time. Something like this:
start thread
do some stuff
join thread with timeout
The thread code is something like this:
int Counter = 0;
while (some_condition)
{
  Console.WriteLine("Counter:"+Counter.ToString());
  Sleep(100);
  //do some processing
}
Hope this makes sense. It is a very simple case.

Einar

>Einar,
>
>Does your app join to all of the threads or just one/some of them? The debug code, where is it? Will it fire only after you've joined the thread or whether or not you join it? Remember, threads are not guaranteed to be processed in any particular order. A lot of factors go into determining when and how threads are processed. From the little bit of debugging output you have given and the little I know about your project (which is nothing), I could only speculate as to what is happening. My first guess would be that you are kicking off 4 threads, joining the third one (Counter:2) and it is finishing before the fourth thread. Obviously, that may not even be close, but I'd need more info to continue.
>
>HTH,
>Chad
>
>>I have a thread that I join using the overload Join method that accepts a timeout parameter and I see something like the following in the output window:
>>
>>The thread 'The Name of my thread' (0xd88) has exited with code 0 (0x0).
>>
>>
>>I added some debug/test code to the method that is running in the thread to print stuff to the console. Here is the code I added:
>>
>>Console.WriteLine("Counter:"+Counter.ToString());
>>
>>
>>Now the text in the output window will be something like this:
>>
>>Counter:0
>>Counter:1
>>Counter:2
>>The thread 'The Name of my thread' (0xd88) has exited with code 0 (0x0).
>>Counter:3
>>
>>
>>The code is running fine and everything is OK, but why does the line Counter:3 show up after the thread has exited?
>>
>>Any information on the subject is welcome.
>>
>>Thanks,
>>Einar
Semper ubi sub ubi.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform