Custom Threaded Objects
Technically, there is no relation between threads and objects. A single method in an object can be executed by several different threads, and a single thread can span multiple methods in different objects. However, it’s often useful to create a dedicated class that encapsulates everything a thread needs. This provides an easy way to associate pieces of required information with a thread and overcome the fundamental limitation that a thread can execute only methods that take no parameters.
Consider, for example, the asynchronous calls to an imaginary stock quote XML Web service, which we considered earlier in the chapter. The GetStockQuote Web method required a single ticker parameter and returned a decimal with price information. ...
Get Microsoft® .NET Distributed Applications: Integrating XML Web Services and .NET Remoting 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.