Autor Beitrag
BlackMatrix
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 243
Erhaltene Danke: 1



BeitragVerfasst: Fr 21.05.10 00:36 
Hi.

Ich rufe in meinem Threadpool eine Methode auf und es werden etwa 20 Threads erzeugt.

Nun will ich im Hauptthread aktiv darauf warten, dass alle fertig werden und das Programm danach beenden.

ausblenden C#-Quelltext
1:
2:
3:
4:
foreach(string element in txt)
ThreadPool.QueueUserWorkItem(new WaitCallback(methode), element);

            while ([???]) Thread.Sleep(1000);
gfoidl
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 157
Erhaltene Danke: 19

Win XP
C#, Fortran 95 - Visual Studio
BeitragVerfasst: Fr 21.05.10 12:54 
Hallo,

schau dir mal die WaitHandles an: AutoResetEvent und ManualResetEvent.


mfG Gü

_________________
Alle sagten, das geht nicht! Dann kam einer, der wusste das nicht - und hat's gemacht!
Kha
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3803
Erhaltene Danke: 176

Arch Linux
Python, C, C++ (vim)
BeitragVerfasst: Fr 21.05.10 13:00 
Ab .NET 4 wäre Task.WaitAll zu empfehlen. Oder, wenn der Hauptthread gar nicht blockiert werden soll, Task.Factory.ContinueWhenAll.

_________________
>λ=
BlackMatrix Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 243
Erhaltene Danke: 1



BeitragVerfasst: Mo 24.05.10 17:51 
Danke, habs hinbekommen :)