Click here to Skip to main content
15,895,606 members
Home / Discussions / C#
   

C#

 
AnswerRe: Simple array use, no looping = StackOverflowException? Pin
NassosReyzidis7-Jun-07 4:34
NassosReyzidis7-Jun-07 4:34 
AnswerRe: Simple array use, no looping = StackOverflowException? Pin
Ian Shlasko7-Jun-07 4:35
Ian Shlasko7-Jun-07 4:35 
GeneralRe: Simple array use, no looping = StackOverflowException? Pin
revi227-Jun-07 4:58
revi227-Jun-07 4:58 
AnswerRe: Simple array use, no looping = StackOverflowException? Pin
Christian Bailey7-Jun-07 10:30
Christian Bailey7-Jun-07 10:30 
QuestionThreadPool. Any way to know when all threads finished? Pin
Diego F.7-Jun-07 4:06
Diego F.7-Jun-07 4:06 
AnswerRe: ThreadPool. Any way to know when all threads finished? Pin
Dave Kreskowiak7-Jun-07 4:44
mveDave Kreskowiak7-Jun-07 4:44 
GeneralRe: ThreadPool. Any way to know when all threads finished? Pin
Diego F.7-Jun-07 4:52
Diego F.7-Jun-07 4:52 
AnswerRe: ThreadPool. Any way to know when all threads finished? Pin
Luc Pattyn7-Jun-07 4:50
sitebuilderLuc Pattyn7-Jun-07 4:50 
Hi,

AFAIK there is no built-in mechanism for this.

I see at least three possibilities:

1.
You could try to count yourself; use Interlocked.Increment each time you send
a piece of work to a thread, and have it call Interlocked.Decrement when it is done.
Then have your main thread do a busy wait (with Sleep!) on the same counter.

disadvantages:
- if a thread exits abnormally (or forgets to decrement) your main
thread will hang forever.
- the wait loop is not nice.

2.
Since .NET 2.0 there is BackgroundWorker class, which supports cancellation and
offers events. You could use its IsBusy property and/or its ProgressChanged event.

3.
And of course you could use regular threads, keep them in a list, and periodically
check their status. (Dont forget to clear the list when you conclude all has been
done; so the threads get garbage collected).

Smile | :)


GeneralRe: ThreadPool. Any way to know when all threads finished? Pin
Diego F.7-Jun-07 4:56
Diego F.7-Jun-07 4:56 
GeneralRe: ThreadPool. Any way to know when all threads finished? Pin
Luc Pattyn7-Jun-07 5:13
sitebuilderLuc Pattyn7-Jun-07 5:13 
GeneralRe: ThreadPool. Any way to know when all threads finished? Pin
Dave Kreskowiak7-Jun-07 5:28
mveDave Kreskowiak7-Jun-07 5:28 
QuestionPassword Permission Pin
Saiyed Alam7-Jun-07 3:54
Saiyed Alam7-Jun-07 3:54 
AnswerRe: Password Permission Pin
Dave Kreskowiak7-Jun-07 4:38
mveDave Kreskowiak7-Jun-07 4:38 
GeneralRe: Password Permission Pin
Dan Neely7-Jun-07 7:31
Dan Neely7-Jun-07 7:31 
GeneralRe: Password Permission Pin
Dave Kreskowiak7-Jun-07 8:21
mveDave Kreskowiak7-Jun-07 8:21 
AnswerRe: Password Permission Pin
Rick van Woudenberg7-Jun-07 5:02
Rick van Woudenberg7-Jun-07 5:02 
AnswerRe: Password Permission Pin
Dan Neely7-Jun-07 7:29
Dan Neely7-Jun-07 7:29 
QuestionDouble seperator disappears upon insert in DB Pin
Rick van Woudenberg7-Jun-07 3:37
Rick van Woudenberg7-Jun-07 3:37 
AnswerRe: Double seperator disappears upon insert in DB Pin
Ian Shlasko7-Jun-07 4:38
Ian Shlasko7-Jun-07 4:38 
GeneralRe: Double seperator disappears upon insert in DB Pin
Rick van Woudenberg7-Jun-07 5:26
Rick van Woudenberg7-Jun-07 5:26 
GeneralRe: Double seperator disappears upon insert in DB Pin
Ian Shlasko7-Jun-07 12:01
Ian Shlasko7-Jun-07 12:01 
GeneralRe: Double seperator disappears upon insert in DB Pin
Rick van Woudenberg8-Jun-07 13:07
Rick van Woudenberg8-Jun-07 13:07 
Question[Message Deleted] Pin
Ankit Aneja7-Jun-07 3:07
Ankit Aneja7-Jun-07 3:07 
AnswerRe: Filename.indexof Pin
Sathesh Sakthivel7-Jun-07 3:12
Sathesh Sakthivel7-Jun-07 3:12 
AnswerRe: Filename.indexof Pin
Anthony Surendran7-Jun-07 3:20
Anthony Surendran7-Jun-07 3:20 

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.