Where Are We?


The pi calculator example demonstrates how to perform long-running operations while displaying a progress dialog and keeping the UI responsive to user interaction. You use the BackgroundWorker component to spawn worker threads and safely pass data between UI and worker threads. Although you could use shared data, it's better to use BackgroundWorker's implicit message-passing scheme between threads to avoid the complications of synchronization. A subset of the internals used by BackgroundWorker is also used to generate web services proxy classes, resulting in a familiar coding model for long-running web service calls. VS05 also turns web service references into components for easier design-time configuration and coding.

.NET has extensive threading support, so you can certainly use techniques other than message passing to achieve the same ends. Whatever method you choose, it's important to remember that a worker thread can neither call methods nor set properties on any control created on the UI thread; only the UI thread can do that. Of all the options, though, BackgroundWorker provides the lowest bar of entry for safely creating worker threads.




Windows Forms 2.0 Programming
Windows Forms 2.0 Programming (Microsoft .NET Development Series)
ISBN: 0321267966
EAN: 2147483647
Year: 2006
Pages: 216

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