advertisement
Login | Register   
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Download the code for this article
How the Asynchronous Model Works
What did you think of this article? Did the sample code help? Do you like the fact that Microsoft added the new asynchronous features? Do you like the way they're implemented? Do you think it could be even easier? If so, how? Let us know in the .NET Technical discussion forum.
Partners & Affiliates
advertisement
advertisement
advertisement
advertisement
Average Rating: 5/5 | Rate this item | 2 users have rated this item.
 

Build Better UIs with the Asynchronous Support in .NET 2.0

Good user interfaces let users keep working as seamlessly as possible while an application performs long background processing tasks. While .NET 1.0 certainly simplified the process of launching and managing multiple threads in Windows applications, you had to write much of the infrastructure yourself. In contrast, .NET 2.0 adds direct framework support for asynchronously fetching data and performing background tasks. 


advertisement
synchronous programming has always been a difficult and time-consuming process in Windows programming. Until now, developers typically wrote asynchronous code in .NET by using an asynchronous pattern with a Begin/End method that returned an IAsyncResult object, using either delegates or an explicit threading technique as the model. However, it's far better to have an infrastructure-based approach with intrinsic support for asynchronous processing within .NET controls and libraries. The .NET framework version 2.0 takes this approach by providing a standard asynchronous pattern with a base infrastructure that helps you either use the intrinsic framework-supplied BackgroundWorker component in your classes or for building your components manually with asynchronous support. In addition, Whidbey natively supports asynchronous processing for many controls and for T-SQL statements. In this article, you'll see how to use the model to fetch data asynchronously using a SqlCommand object, and how to build a class that uses the BackGroundWorker component.


Author Note: The sample code that accompanies this article uses VS.NET Beta for the samples. The DataBindingEx.sln requires the "Yukon" version of SQL Server, but the other samples do not.

Although this article focuses on asynchronous programming in Whidbey it is important that you understand the asynchronous model itself. The sidebar "How the Asynchronous Model Works" provides several examples. If you're not thoroughly familiar with programming asynchronous operations, review the sidebar before reading the rest of this article.

Asynchronous Scenarios in .NET 2.0
The rest of this article contains a practical sample of programming asynchronous processes in .NET 2.0. The first scenario involves an asynchronous data fetch using the new Asynchronous support offered in the SqlCommand object. Later, I'll show you how to use the new BackGroundWorker component.

  Next Page: Fetching Data Asynchronously


Page 1: IntroductionPage 5: Implementing BackGroundWorker Events
Page 2: Fetching Data AsynchronouslyPage 6: Searching the File Set
Page 3: Choose an Appropriate OverloadPage 7: Displaying Search Results and Progress
Page 4: Asynchronous Background Processing 
Please rate this item (5=best)
 1  2  3  4  5
advertisement