Patent ID: 8756604

Claim:
A method, implemented at a computer system that includes one or more processors and system memory, the method for handling completion of an asynchronous operation, the method comprising: an act of an async wrapper receiving a request to execute an asynchronous operation from a calling context, the async wrapper comprising a wrapper for the asynchronous operation and being configured to execute the asynchronous operation on behalf of the calling context; an act of the async wrapper setting a state flag, including: based on determining that the request originated from an asynchronous routine, setting the state flag to a first state; and based on determining that the request originated from a sync-over-async wrapper which is awaiting a notification that the asynchronous operation has completed, setting the state flag to a second state; an act of the async wrapper initiating execution of the asynchronous operation; an act of the async wrapper detecting completion of the asynchronous operation; and based on the state flag, an act of the async wrapper providing results of the asynchronous operation to the calling context, including: when the state flag indicates the first state: an act of the async wrapper marshaling results of the asynchronous operation to the asynchronous routine; and when the state flag indicates the second state: an act of the async wrapper storing results of the asynchronous operation at a particular location that is accessible by both the async wrapper and the synchronous routine, the particular location being accessible by the async wrapper even though the synchronous routine is blocked; and an act of the async wrapper signaling completion of the asynchronous operation to the sync-over-async wrapper, resulting in the synchronous routine unblocking and retrieving the stored results from the particular location.