Multithreading Patterns






Summary

This chapter used a step-by-step approach to setting up both the asynchronous results pattern and the background worker pattern. The asynchronous results pattern provides support for calling any method asynchronously, even a method written by a third party. It includes a notification mechanism about method execution completion via a callback on a delegate passed when setting up the pattern. One drawback to the asynchronous results pattern is that there is no inherent mechanism for posting the status of the asynchronous method. However, the .NET Framework 2.0 provides this functionality in a second multithreading pattern called the background worker pattern. The key about this pattern is that it includes support for notification of status (without polling), completion, and errors. To support this, however, the pattern requires special code hooks within the asynchronously invoked method. This prevents developers from using it on methods for which they have no source code, or if they are unwilling to code special hooks. Calling long-running methods provided by third parties, for example, prevents the support for embedding the callback hooks within the methods.

The next chapter investigates another fairly complex .NET technology: that of marshaling calls out of .NET and into managed code using P/Invoke. In addition, it introduces a concept known as unsafe code, which is used to access memory pointers directly, as in C++.



 Python   SQL   Java   php   Perl 
 game development   web development   internet   *nix   graphics   hardware 
 telecommunications   C++ 
 Flash   Active Directory   Windows