예제 #1
0
        public static void EndInvoke(IAsyncResult result, object owner)
        {
            AsyncResultNoResult ar = result as AsyncResultNoResult;

            if (ar == null)
            {
                throw new ArgumentException("Result passed represents an operation not supported " +
                                            "by this framework.");
            }

            ar.CheckUsage(owner);

            // This method assumes that only 1 thread calls EndInvoke for this object
            if (!ar.IsCompleted)
            {
                // If the operation isn't done, wait for it
                ar.AsyncWaitHandle.WaitOne();
                ar.AsyncWaitHandle.Close();
                ar.m_asyncWaitHandle = null; // Allow early GC
            }
            // Operation is done: if an exception occured, throw it
            if (ar.m_exception != null)
            {
                throw ar.m_exception;
            }
        }
예제 #2
0
 protected virtual void MakeCallback(AsyncCallback callback, AsyncResultNoResult result)
 {
     // If a callback method was set, call it
     if (callback != null)
     {
         callback(result);
     }
 }
예제 #3
0
        public new static TResult EndInvoke(IAsyncResult asyncResult, object owner)
        {
            AsyncResult <TResult> ar = asyncResult as AsyncResult <TResult>;

            if (ar == null)
            {
                throw new ArgumentException("Result passed represents an operation not supported " +
                                            "by this framework.");
            }
            AsyncResultNoResult.EndInvoke(asyncResult, owner);
            return(ar.m_result);
        }