/// <summary> /// Internal event handler. /// </summary> /// <param name="result"></param> /// <returns></returns> protected override bool OnEndWaitForChannel(IAsyncResult result) { AsyncResult <bool, object> arWait = (AsyncResult <bool, object>)result; arWait.Wait(); try { return(arWait.Exception == null && arWait.Result); } finally { arWait.Dispose(); } }
/// <summary> /// Completes an asynchronous operation initiated by <see cref="BeginWaitForMessage" />. /// </summary> /// <param name="result">The <see cref="IAsyncResult" /> instance returned by <see cref="BeginWaitForMessage" />.</param> /// <returns><c>true</c> if the channel has queued a received message.</returns> public bool EndWaitForMessage(IAsyncResult result) { AsyncResult <bool, InputChannel> arWait = (AsyncResult <bool, InputChannel>)result; Assertion.Test(arWait.InternalState != null, "InternalState should have been set to the channel."); arWait.Wait(); try { return(arWait.Exception == null && arWait.Result); } finally { arWait.Dispose(); } }
/// <summary> /// Internal event handler. /// </summary> /// <param name="result"></param> protected override void OnEndClose(IAsyncResult result) { AsyncResult ar = (AsyncResult)result; ar.Wait(); try { if (ar.Exception != null) { throw ar.Exception; } } finally { ar.Dispose(); } }
/// <summary> /// Completes an asynchronous operation initiated by one of the <b>BeginSend()</b> overrides. /// </summary> /// <param name="result">The <see cref="IAsyncResult" /> instance returned by <b>BeginSend()</b>.</param> public void EndSend(IAsyncResult result) { AsyncResult arSend = (AsyncResult)result; arSend.Wait(); try { if (arSend.Exception != null) { throw ServiceModelHelper.GetCommunicationException(arSend.Exception); } } finally { arSend.Dispose(); } }
/// <summary> /// Internal event handler. /// </summary> /// <param name="result"></param> /// <returns></returns> protected override TChannel OnEndAcceptChannel(IAsyncResult result) { AsyncResult <TInternal, object> arAccept = (AsyncResult <TInternal, object>)result; arAccept.Wait(); try { if (arAccept.Exception != null) { throw arAccept.Exception; } return((TChannel)(object)arAccept.Result); } finally { arAccept.Dispose(); } }
public void EndGetEvent(/*IMFAsyncResult*/ IntPtr pResult, /*IMFMediaEvent*/ out IntPtr ppEvent) { if (pResult == IntPtr.Zero) { throw new ArgumentNullException(); } var ar = new AsyncResult(pResult); MediaEvent ev = null; try { _eventQueue.EndGetEvent(ar, out ev); ppEvent = ev.Detach(); } finally { ev?.Dispose(); ar.NativePointer = IntPtr.Zero; ar.Dispose(); } }
/// <summary> /// Completes an asynchronous operation initiated by <see cref="BeginWaitForMessage" />. /// </summary> /// <param name="result">The <see cref="IAsyncResult" /> instance returned by <see cref="BeginWaitForMessage" />.</param> /// <returns><c>true</c> if the channel has queued a received message.</returns> public bool EndWaitForMessage(IAsyncResult result) { AsyncResult <bool, object> arWait = (AsyncResult <bool, object>)result; arWait.Wait(); try { if (arWait.Exception != null) { return(false); } return(arWait.Result); } finally { arWait.Dispose(); } }
/// <summary> /// Completes an asynchronous message receive operation. /// </summary> /// <param name="result">The <see cref="IAsyncResult" /> returned by one of the <b>BeginReceive()</b> overrides.</param> /// <returns>The <see cref="Message" /> received or <c>null</c> if the remote side of the session has been closed.</returns> public Message EndReceive(IAsyncResult result) { AsyncResult <Message, object> arReceive = (AsyncResult <Message, object>)result; arReceive.Wait(); try { if (arReceive.Exception != null) { throw ServiceModelHelper.GetCommunicationException(arReceive.Exception); } return(arReceive.Result); } finally { arReceive.Dispose(); } }
/// <summary> /// Completes an asynchronous channel message receive operation. /// </summary> /// <param name="result">The <see cref="IAsyncResult" /> returned by <see cref="BeginReceive" />.</param> /// <returns>The <see cref="Message" /> received.</returns> public Message EndReceive(IAsyncResult result) { AsyncResult <Message, InputChannel> arReceive = (AsyncResult <Message, InputChannel>)result; Assertion.Test(arReceive.InternalState != null, "InternalState should have been set to the channel."); arReceive.Wait(); try { if (arReceive.Exception != null) { throw ServiceModelHelper.GetCommunicationException(arReceive.Exception); } return(arReceive.Result); } finally { arReceive.Dispose(); } }
/// <summary> /// Completes an asynchronous message receive operation initiated by <see cref="BeginTryReceive" />. /// </summary> /// <param name="result">The <see cref="IAsyncResult" /> instance returned by <see cref="BeginTryReceive" />.</param> /// <param name="message">Returns as the message received (or <c>null</c>).</param> /// <returns><c>true</c> if a message was received.</returns> public bool EndTryReceive(IAsyncResult result, out Message message) { AsyncResult <Message, object> arReceive = (AsyncResult <Message, object>)result; message = null; arReceive.Wait(); try { if (arReceive.Exception != null) { return(false); } message = arReceive.Result; return(true); } finally { arReceive.Dispose(); } }
/// <summary> /// Completes an asynchronous channel message try-receive operation. /// </summary> /// <param name="result">The <see cref="IAsyncResult" /> returned by <see cref="BeginTryReceive" />.</param> /// <param name="message">Returns as the <see cref="Message" /> received (or <c>null</c>).</param> /// <returns><c>true</c> if a message was received.</returns> public bool EndTryReceive(IAsyncResult result, out Message message) { AsyncResult <Message, InputChannel> arReceive = (AsyncResult <Message, InputChannel>)result; message = null; Assertion.Test(arReceive.InternalState != null, "InternalState should have been set to the channel."); arReceive.Wait(); try { if (arReceive.Exception != null) { return(false); } message = arReceive.Result; return(true); } finally { arReceive.Dispose(); } }
private void OnEndTransfer(ReliableTransferHandler sender, ReliableTransferArgs args) { CloseStream(); if (reliableSession.IsServer) { if (arTransfer.Callback != null) { arTransfer.Notify(args.Exception); } else { // No callback so we'll handle the termination ourselves. arTransfer.Dispose(); closed = true; } } // Note that client side notification is handled by the // ReliableTransferSession class. }
/// <summary> /// Completes an asynchronous channel try-receive request operation. /// </summary> /// <param name="result">The <see cref="IAsyncResult" /> returned by <see cref="BeginTryReceiveRequest" />.</param> /// <param name="requestInfo">Returns as the <see cref="RequestInfo" /> received (or <c>null</c>).</param> /// <returns><c>true</c> if a request was received.</returns> public bool EndTryReceiveRequest(IAsyncResult result, out RequestInfo requestInfo) { AsyncResult <RequestInfo, ReplyChannel> arReceive = (AsyncResult <RequestInfo, ReplyChannel>)result; requestInfo = default(RequestInfo); Assertion.Test(arReceive.InternalState != null, "InternalState should have been set to the channel."); arReceive.Wait(); try { if (arReceive.Exception != null) { return(false); } requestInfo = arReceive.Result; return(true); } finally { arReceive.Dispose(); } }