Click here to Skip to main content
15,909,332 members
Home / Discussions / C#
   

C#

 
QuestionDo you know NET 2.0 documentation tools? Pin
cebyrjoe228-Jan-07 7:35
cebyrjoe228-Jan-07 7:35 
AnswerRe: Do you know NET 2.0 documentation tools? Pin
Stefan Troschuetz28-Jan-07 8:12
Stefan Troschuetz28-Jan-07 8:12 
QuestionThread Id and Thread name Pin
MinaFawzi28-Jan-07 5:43
MinaFawzi28-Jan-07 5:43 
AnswerRe: Thread Id and Thread name Pin
Luc Pattyn28-Jan-07 6:11
sitebuilderLuc Pattyn28-Jan-07 6:11 
GeneralRe: Thread Id and Thread name Pin
MinaFawzi28-Jan-07 6:19
MinaFawzi28-Jan-07 6:19 
GeneralRe: Thread Id and Thread name Pin
Luc Pattyn28-Jan-07 7:00
sitebuilderLuc Pattyn28-Jan-07 7:00 
GeneralRe: Thread Id and Thread name Pin
MinaFawzi28-Jan-07 7:14
MinaFawzi28-Jan-07 7:14 
GeneralRe: Thread Id and Thread name Pin
Luc Pattyn28-Jan-07 9:55
sitebuilderLuc Pattyn28-Jan-07 9:55 
Hi,

the following is not correct, it gives the ideas, first for .NET 1.1 then 2.0

with .NET 1.1:

when you create a thread, insert it in a hashtable
Thread thread=new Thread(...);
threadHash.Add(thread, "Searching database");  // <<< keep thread and descriptive text
thread.Start();


you can now list all your threads:
foreach (DictionaryEntry de in treadHash) {
    string descr=(string)de.Value;
    Thread thread=(Thread)de.Key;
    ...show the thread, its ID, its state and descr
}


the only caveat is: doing this keeps all thread objects alive, since they are all in
the hashtable, so you should try to throw away the ones you dont need anymore,
either with threadHash.Remove() when a thread comes to an end,
or by periodically checking the thread states.

with .NET 2.0:

when you create a thread, insert it in a hashtable
Thread thread=new Thread(...);
threadHash.Add(thread.ManagedThreadID, "Searching database");  // <<< keep ID and descr
thread.Start();


you can now list all your threads using
foreach (Thread thread in processThreadCollection) {
    string descr=threadHash[thread.ID];
    ...show the thread, its ID, its state and descr
}


Since you are not holding a collection of thread, there is no cleanup problem.

Smile | :)




Luc Pattyn

AnswerRe: Thread Id and Thread name Pin
Parwej Ahamad28-Jan-07 6:28
professionalParwej Ahamad28-Jan-07 6:28 
GeneralRe: Thread Id and Thread name Pin
MinaFawzi28-Jan-07 7:10
MinaFawzi28-Jan-07 7:10 
GeneralRe: Thread Id and Thread name Pin
Parwej Ahamad28-Jan-07 7:13
professionalParwej Ahamad28-Jan-07 7:13 
GeneralRe: Thread Id and Thread name Pin
MinaFawzi28-Jan-07 7:17
MinaFawzi28-Jan-07 7:17 
QuestionRetrieve Data from a tablecell using Webbrowser? Pin
TuanNH8528-Jan-07 5:15
TuanNH8528-Jan-07 5:15 
AnswerRe: Retrieve Data from a tablecell using Webbrowser? Pin
Parwej Ahamad28-Jan-07 6:56
professionalParwej Ahamad28-Jan-07 6:56 
GeneralRe: Retrieve Data from a tablecell using Webbrowser? Pin
TuanNH8528-Jan-07 18:56
TuanNH8528-Jan-07 18:56 
QuestionStore DXF files (Autocad files) in SQLSERVER And be able zoom Pin
Hossein Malekizadeh28-Jan-07 3:53
Hossein Malekizadeh28-Jan-07 3:53 
Questionnotepad.exe Pin
zeltera28-Jan-07 3:15
zeltera28-Jan-07 3:15 
AnswerRe: notepad.exe Pin
engsrini28-Jan-07 4:22
engsrini28-Jan-07 4:22 
AnswerRe: notepad.exe Pin
Thomas Stockwell28-Jan-07 4:45
professionalThomas Stockwell28-Jan-07 4:45 
AnswerRe: notepad.exe Pin
zeltera28-Jan-07 5:00
zeltera28-Jan-07 5:00 
GeneralRe: notepad.exe Pin
Luc Pattyn28-Jan-07 6:15
sitebuilderLuc Pattyn28-Jan-07 6:15 
GeneralRe: notepad.exe Pin
zeltera28-Jan-07 7:25
zeltera28-Jan-07 7:25 
GeneralRe: notepad.exe Pin
bobsugar22228-Jan-07 22:26
bobsugar22228-Jan-07 22:26 
GeneralRe: notepad.exe Pin
zeltera29-Jan-07 0:37
zeltera29-Jan-07 0:37 
QuestionCreating and invoking instance of Action using reflection Pin
Girb28-Jan-07 3:11
Girb28-Jan-07 3:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.