i want to start 6 Threads asynchronously, paused them and resume synchronously…
it should work like this one:
- Thread 1 starting (thr1.start())
- Thread 1 some progress (getting mac-adresses from txt-file, initializing com-objects)
- Thread 1 paused (paused until all threads did the same as thread 1)
- Thread 2 starting
- Thread 2 some progress
- Thread 2 paused
- Thread 3 starting
- Thread 3 some progress
- Thread 3 paused
- …
- after all 6 thread paused, they should resume all..
i tried with 6 simple boolean flags and wait until they are all true but thats quite a bit dirty…
any ideas?
EDIT (better visualization):
Thr1 | Initiliazing |waiting |waiting | Resuming
Thr2 | waiting |Initiliazing |waiting | Resuming
Thr3 | waiting |waiting |Initiliazing | Resuming
...
thanks and greetz,
flux
You want some sort of synchronization – a ManualResetEvent for each thread sounds likely, depending on your thread functions.
EDIT: Thanks for your updates – here’s a basic example:
Note that the
StartThreadsmethod will block while the threads initialize – this may or may not be a problem.