Where Are We?

The pi calculator example demonstrates how to perform long-running operations while still displaying a progress dialog and keeping the UI responsive to user interaction. Not only does it leverage multiple threads to split the UI from a long-running operation, but also the UI thread communicates further user input back to the worker thread to adjust its behavior. Although it could use shared data, the application uses a message passing scheme between threads to avoid the complications of synchronization.

.NET has extensive threading support, so techniques other than message passing can certainly be used to achieve the same ends. However, whatever method you choose, it's important to remember that a worker thread cannot call methods ...

Get Windows Forms Programming in C# now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.