Content deleted Content added
→Further reading: you can't have both the isbn 10 and the isbn 13 in a cite format |
Rm conflicting parameter from reference |
||
Line 33:
One can also pass a callback method to <code>BeginAccomplish</code>, to be invoked when the long-running method completes. It typically calls <code>EndAccomplish</code> to obtain the return value of the long-running method. A problem with the callback mechanism is that the callback function is naturally executed in the worker thread (rather than in the original calling thread), which may cause race conditions.<ref name="ms228972">{{cite web |url=http://msdn.microsoft.com/en-us/library/ms228972.aspx |title=Using an AsyncCallback Delegate to End an Asynchronous Operation |accessdate= 22 November 2008 |work=.NET Framework Developer's Guide |publisher=Microsoft Developer Network| archiveurl= http://web.archive.org/web/20081223205326/http://msdn.microsoft.com/en-us/library/ms228972.aspx| archivedate= 23 December 2008 <!--DASHBot-->| deadurl= no}}</ref><ref name="Async.34.3#76161">{{cite web |url=http://www.zeroc.com/doc/Ice-3.2.1/manual/Async.34.3.html#76161 |title=Concurrency Issues |accessdate= 22 November 2008 |work=Distributed Programming with Ice |publisher=ZeroC, Inc.}}</ref>
In the .NET Framework documentation, the term event-based asynchronous pattern refers to an alternative API style (available since .NET 2.0) using a method named <code>AccomplishAsync</code> instead of <code>BeginAccomplish</code>.<ref name=nageletal>{{cite book|title=Professional C# 2008|author=Christian Nagel, Bill Evjen, Jay Glynn, Karli Watson, and Morgan Skinner|pages=570–571|publisher=Wiley|year=2008
A superficial difference is that in this style the return value of the long-running method is passed directly to the callback method. Much more importantly, the API uses a special mechanism to run the callback method (which resides in an event object of type <code>AccomplishCompleted</code>) in the same thread in which <code>BeginAccomplish</code> was called. This eliminates the danger of race conditions, making the API easier to use and suitable for software components; on the other hand this implementation of the pattern comes with additional object creation and synchronization overhead.<ref name="ms228966">{{cite web |url=http://msdn.microsoft.com/en-us/library/ms228966.aspx |title=Deciding When to Implement the Event-based Asynchronous Pattern |accessdate= 22 November 2008 |work=.NET Framework Developer's Guide |publisher=Microsoft Developer Network| archiveurl= http://web.archive.org/web/20081122092048/http://msdn.microsoft.com/en-us/library/ms228966.aspx| archivedate= 22 November 2008 <!--DASHBot-->| deadurl= no}}</ref>
|