Page 181 - DCAP507_SYSTEM_SOFTWARE
P. 181
Unit 11: Programming Languages Concept (II)
If the asynchronous operation demonstrated by the IAsyncResult object has not accomplished Notes
when EndOperationName is called, EndOperationName blocks the calling thread until the
asynchronous operation is complete. Exceptions thrown by the asynchronous operation are
thrown from the EndOperationName method. The result of calling the EndOperationName
method various times with the same IAsyncResult is not defined. Similarly, calling the
EndOperationName method with an IAsyncResult that was not returned by the associated Begin
method is also not defined.
!
Caution For any of the undefined scenarios, implementers should consider throwing
InvalidOperationException.
Notes Implementers of this design outline should notify the caller that the asynchronous
operation accomplished by setting IsCompleted to true, calling the asynchronous callback
method (if one was stated) and signaling the AsyncWaitHandle.
Application developers have numerous design options for processing the results of the
asynchronous operation.
Did u know? The accurate choice is based on whether the application has directions that can
implement while the operation finishes.
If an application cannot execute any additional work until it obtains the results of the asynchronous
operation, the application must block until the results are obtainable. To obstruct until an
asynchronous operation completes, you can utilize one of the following strategies:
Call EndOperationName from the application's main thread, obstructing application
execution until the operation is finished.
Use the AsyncWaitHandle to obstruct application execution until one or more operations
are complete.
Applications that do not necessitate blocking while the asynchronous operation accomplishes
can use one of the following strategies:
Poll for operation completion status by verifying the IsCompleted property periodically
and calling EndOperationName when the operation is complete.
Use an AsyncCallback delegate to state a method to be invoked when the operation is
complete.
11.2.3 Asynchronous Operations Conditions and Signals
An asynchronous operation is initiated by a function that is named with the prefix async_. These
functions will be pointed to as initiating functions.
All initiating functions take a function object meeting handler needs as the final parameter.
These handlers accept as their first parameter an value of type const error_code.
Executions of asynchronous operations may call the Application Programming Interface (API)
offered by the operating system. If such an operating system API call effect in an error, the
handler will be invoked with a const error_code l value that evaluates to true. Or else the
handler will be invoked with a const error_code l value that evaluates to false.
LOVELY PROFESSIONAL UNIVERSITY 175