internal void WaitUntilComplete() { if (!IsCompleted) { AsyncWaitHandle.WaitOne(); } }
public Message WaitForReply(TimeSpan timeout) { var retval = AsyncWaitHandle.WaitOne((int)timeout.TotalMilliseconds, false); lock (ThisLock) { Dispose(false); if (_aborted) { if (_requestException != null) { throw _requestException; } else { throw new CommunicationObjectAbortedException("RequestContext aborted"); } } if (retval == false) { Abort(); throw new CommunicationObjectAbortedException("RequestContext timeout"); } } return(_response); }
/// <summary> /// Frees up resources used by the asynchronous operation represented by the IAsyncResult passed. /// If the asynchronous operation failed, this method throws the exception. /// </summary> public void EndInvoke() { // This method assumes that only 1 thread calls EndInvoke for this object // If the operation isn't done or if the wait handle was created, wait for it if (!IsCompleted || (m_AsyncWaitHandle != null)) { AsyncWaitHandle.WaitOne(); } // If the wait handle was created, close it #pragma warning disable 420 ManualResetEvent mre = Interlocked.Exchange(ref m_AsyncWaitHandle, null); #pragma warning restore 420 if (mre != null) { mre.Close(); } // Operation is done: if an exception occurred, throw it if (m_exception != null) { throw m_exception; } }
/// <devdoc> /// <para> /// Causes an abort of any aborted requests waiting in the ConnectionGroup /// </para> /// </devdoc> private void Abort() { lock (m_ConnectionList) { m_Abort = true; AsyncWaitHandle.Set(); } }
/// <summary> /// Waits for completion. /// </summary> public void WaitForCompletion() { if (!isCompleted) { AsyncWaitHandle.WaitOne(); } }
internal bool End() { if (_ended) { throw new InvalidOperationException(); } _ended = true; if (!IsCompleted) { AsyncWaitHandle.WaitOne(); } if (_event != null) { _event.Close(); } if (_exception != null) { throw _exception; } return(_aborted); }
public void Dispose() { if (AsyncWaitHandle != null) { AsyncWaitHandle.Dispose(); _handle = null; } }
/// <devdoc> /// <para> /// Causes an abort of any aborted requests waiting in the ConnectionGroup /// </para> /// </devdoc> private bool Abort(HttpWebRequest request, WebException webException) { lock (m_ConnectionList) { AsyncWaitHandle.Set(); } return(true); }
internal bool WaitUntilComplete(int timeout, bool exitContext) { if (IsCompleted) { return(true); } return(AsyncWaitHandle.WaitOne(timeout, exitContext)); }
internal void WaitUntilComplete() { if (_isCompleted) { return; } AsyncWaitHandle.WaitOne(); }
public WaitAsyncResult(AsyncWaitHandle waitHandle, AsyncCallback callback, object state, TimeSpan timeout) : base(callback, state) { this.waitHandle = waitHandle; if (this.waitHandle.WaitAsync(PrefetchAsyncWaitHandle.WaitAsyncResult.onWaitCallback, this, timeout)) { base.Complete(true); } }
public void Wait() { if (IsCompleted) { return; } AsyncWaitHandle.WaitOne(); }
/// <devdoc> /// <para> /// Called when a connection is idle and ready to process new requests /// </para> /// </devdoc> internal void ConnectionGoneIdle() { if (m_AuthenticationGroup) { lock (m_ConnectionList) { AsyncWaitHandle.Set(); } } }
internal int Wait() { AsyncWaitHandle.WaitOne(); if (Error != null) { throw Error; } return(ReadCount); }
internal CloseAsyncResult(AsyncWaitHandle asyncWaitHandle, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state) { this.asyncWaitHandle = asyncWaitHandle; if (this.asyncWaitHandle.WaitAsync(onWaitCompleted, this, timeout)) { Complete(true); } }
/// <devdoc> /// <para> /// Called when a connection is idle and ready to process new requests /// </para> /// </devdoc> internal void ConnectionGoneIdle() { if (m_AuthenticationGroup) { lock (m_ConnectionList) { GlobalLog.Print("ConnectionGroup::ConnectionGoneIdle() setting the event"); AsyncWaitHandle.Set(); } } }
internal byte[] End( ) // Wait for completion + rethrow any error. { AsyncWaitHandle.WaitOne( ); AsyncWaitHandle.Close( ); if (_exception != null) { throw _exception; } return(_data); }
internal void ErrorCleanup() { if (pOverlapped != null) { Overlapped.Unpack(pOverlapped); Overlapped.Free(pOverlapped); pOverlapped = null; } AsyncWaitHandle.Close(); }
void Dispose(bool disposing) { if (disposing) { if (AsyncWaitHandle != null) { AsyncWaitHandle.Close(); } } }
internal void EndInvoke() { AsyncWaitHandle.WaitOne(); AsyncWaitHandle.Close(); _completedWaitHandle = null; // allow early GC if (null != _exception) { throw _exception; } }
internal IMessage EndInvoke() { lock (this) { if (completed) { return(reply_message); } } AsyncWaitHandle.WaitOne(); return(reply_message); }
/// <summary> /// When called in the dervied classes, wait for completion. /// It throws exception if the async operation ends with an exception. /// </summary> protected void WaitForCompletion() { if (!IsCompleted) { AsyncWaitHandle.WaitOne(); } if (_exception != null) { throw _exception; } }
internal WebResponse WaitForResponse() { if (!isCompleted) { AsyncWaitHandle.WaitOne(); } if (exception != null) { throw exception; } return(response); }
internal int Complete() { lock (MonitorWaitHandle) if (!IsCompleted) { Monitor.Wait(MonitorWaitHandle); } if (ErrorCode != 0) { throw new Win32Exception(ErrorCode); } AsyncWaitHandle.Close(); return(Result); }
public T FetchResultsFromAsyncOperation() { if (!_isCompleted) { AsyncWaitHandle.WaitOne(); AsyncWaitHandle.Close(); } if (_exception != null) { throw _exception; } return(_result); }
public void EndConnect() { if (!fComplete) { AsyncWaitHandle.WaitOne(); } this.Dispose(); if (this.fFailure != null) { throw this.fFailure; } }
public void EndInvoke() { if (!IsCompleted) { AsyncWaitHandle.WaitOne(); AsyncWaitHandle.Close(); m_AsyncWaitHandle = null; } if (m_exception != null) { throw m_exception; } }
/// <summary> /// Task EndXXX method called /// </summary> public void EndInvoke() { if (!IsCompleted) { AsyncWaitHandle.WaitOne(); AsyncWaitHandle.Close(); _waitHandle = null; } if (_terminatingException != null) { throw _terminatingException; } }
// we're guaranteed by CommunicationObject that at most ONE of Close or BeginClose will be called once. private void Cleanup(bool aborting, TimeSpan timeout) { bool needToWait = false; if (this.cleanedUp) { return; } lock (this.ThisLock) { if (this.cleanedUp) { return; } if (!aborting && this.retransmitList != null && this.retransmitList.Count > 0) { needToWait = true; this.retransmissionDoneWaitHandle = new AsyncWaitHandle(EventResetMode.ManualReset); } else { // copied this call here in order to avoid releasing then retaking lock this.CleanupAfterWait(aborting); } } if (needToWait) { if (!this.retransmissionDoneWaitHandle.Wait(timeout)) { throw FxTrace.Exception.AsError(new TimeoutException(SR.TimeoutOnOperation(timeout))); } lock (this.ThisLock) { this.retransmissionDoneWaitHandle = null; // another thread could have called Abort while Close() was waiting for retransmission to complete. if (this.cleanedUp) { return; } this.CleanupAfterWait(aborting); } } }
internal T EndOperation() { while (true) { if (IsCompleted) { if (Exception != null) { throw Exception; } return(Result); } AsyncWaitHandle.WaitOne(); } }
public void SetInteriorTransaction(Transaction interiorTransaction, bool needsCommit) { Fx.Assert(!this.context.IsHostTransaction, "SetInteriorTransaction called for a host transaction."); if (this.waitForTransaction != null) { throw Fx.Exception.AsError(new InvalidOperationException(SRCore.ExecuteMustBeNested)); } bool success = false; try { this.waitForTransaction = new AsyncWaitHandle(EventResetMode.ManualReset); interiorTransaction.EnlistVolatile(this, EnlistmentOptions.None); success = true; } finally { if (!success) { if (this.waitForTransaction != null) { this.waitForTransaction.Set(); } } else if (needsCommit) { this.transactionToCommit = (CommittableTransaction)interiorTransaction; } } }
public BindReclaimedLockAsyncResult(InstancePersistenceContext context, AsyncWaitHandle wait, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state) { this.context = context; if (wait.WaitAsync(BindReclaimedLockAsyncResult.waitComplete, this, timeout)) { this.context.ConcludeBindReclaimedLockHelper(); Complete(true); } }
internal BindReclaimedLockException(AsyncWaitHandle markerWaitHandle) : base(SRCore.BindReclaimedLockException) { MarkerWaitHandle = markerWaitHandle; }
bool DoAfterTransaction() { AcquireContextAsyncResult setWaitTo = null; try { lock (this.handle.ThisLock) { if (!this.handle.IsValid) { throw Fx.Exception.AsError(new OperationCanceledException(SRCore.HandleFreed)); } if (HostTransaction == null) { this.executionContext = new InstancePersistenceContext(this.handle, this.timeoutHelper.RemainingTime()); } else { this.executionContext = new InstancePersistenceContext(this.handle, HostTransaction); } this.handle.AcquirePending = null; this.handle.CurrentExecutionContext = this.executionContext; this.handle.TooLateToEnlist = false; } if (HostTransaction != null) { WaitForHostTransaction = new AsyncWaitHandle(EventResetMode.ManualReset); HostTransaction.EnlistVolatile(this, EnlistmentOptions.None); setWaitTo = this; } } finally { this.handle.CurrentTransactionalAsyncResult = setWaitTo; } return true; }