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 nor set properties on a control. Only the UI thread can do that. The Control.InvokeRequire property tells you whether you need to transition from a worker thread to a UI thread, and the Control.Invoke and Control.BeginInvoke methods perform the transition for you.



Windows Forms Programming in Visual Basic .NET
Windows Forms Programming in Visual Basic .NET
ISBN: 0321125193
EAN: 2147483647
Year: 2003
Pages: 139

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net