Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call a method once a ThreadPool thread completes its work

I have to run some piece of code as a separate thread on ThreadPool.

ThreadPool.QueueUserWorkItem(MyMethod,MyObjects);

I need to run another method MyMethod2 once MyMethod is completed. How can I do that?

like image 995
Silverlight Student Avatar asked Feb 03 '26 15:02

Silverlight Student


1 Answers

Here's a way to do it:

ThreadPool.QueueUserWorkItem(o => { MyMethod(o); MyOtherMethod(); }, MyObjects);
like image 79
Thomas Levesque Avatar answered Feb 05 '26 04:02

Thomas Levesque