Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to give callback for threads created using Thread class

Is it possible to give callback(announcing completion of activity) for threads created using Thread class. I have created the thread the following way but could not find a way to give the callback.

Thread thread = new Thread(StartPoll);
thread.SetApartmentState(ApartmentState.STA);

thread.Start();
like image 740
logeeks Avatar asked Feb 20 '23 14:02

logeeks


1 Answers

Not directly. But you can always do something like:

new Thread(() => { StartPoll(); Callback(); })
like image 163
svick Avatar answered May 10 '23 18:05

svick