Saturday, November 13, 2010

Worker Thread

If we are writing a program to check prime number through a list which has more than 10 Lac number. This process will take time and in the mean time if user want to exit the application he can’t do that since interface would not be visible to him.

In that case if want that user can close the application in the middle if want than we have to call Application.DoEvents() or we to have use a separate thread to check the prime number in that case interface would be visible to user and responsive.

In this scenario if user click on cancel button we have to use ManualResetEvent to signal the first thread to stop.

The very first thread that is checking for prime number it is called worker thread.

No comments: