Click here to Skip to main content
15,921,841 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI Friend,


I am running more than 10 threads at once. I want to perform an operation only when thread1 is completes its job. Again thread 3 has to wait until thread 2 finishes.... again same will happen one by one.


Can anyone suggest me how can i do this....

I just made use of Join() but getting an error:

An asynchronous call is already in progress. It must be completed or canceled before you can call this method. System.InvalidOperationExceptionStackTrace: at  System.Net.Mail.SmtpClient.Send(MailMessage message)




Please help me in this regard....
Posted

VB
Thread.ThreadState or Thread.Join if you want to wait for your threads. Or use Semaphore


Thread.join method
 
Share this answer
 
v2
use thread.waitone
this will wait until current gets completed.
 
Share this answer
 
You should be using multiple thread communication here. Here is an article how:

.NET multi-threading and communication between threads[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900