예제 #1
0
 private void SendEndWrapper(ReliableSessionMessage sendMessage, NativeCommon.IFabricAsyncOperationContext context)
 {
     try
     {
         // AppTrace.TraceSource.WriteNoise("NativeReliableSession.EndSend");
         this.nativeReliableSession.EndSend(context);
     }
     finally
     {
         sendMessage.Unpin();
     }
 }
예제 #2
0
        /// <summary>
        /// May be delayed locally if outbound buffer is full (throttling case)
        /// Returns to continuation when the message has been acknowledged as received by the target
        /// </summary>
        /// <param name="message"></param>
        /// <param name="cancellationToken"></param>
        public Task SendAsync(IOperationData message, CancellationToken cancellationToken)
        {
            if (message == null)
            {
                // TODO: do we support null messages, e.g., for pinging purposes?
                throw new ArgumentException(SR.Error_ReliableSession_NullArgument_SendAsync);
            }

            var sendMessage = new ReliableSessionMessage(new OutboundMessage(message));

            //TODO: what if sendMessage is null?
            return(Utility.WrapNativeAsyncInvokeInMTA(
                       (callback) => this.SendBeginWrapper(sendMessage, callback),
                       (context) => this.SendEndWrapper(sendMessage, context),
                       cancellationToken,
                       "ReliableSession.SendAsync"));
        }
예제 #3
0
        private NativeCommon.IFabricAsyncOperationContext SendBeginWrapper(
            ReliableSessionMessage sendMessage, NativeCommon.IFabricAsyncOperationCallback callback)
        {
            try
            {
                var nativeSendMessage = sendMessage.Pin(this.nativeMessageDataFactory);

                // TODO: do we support empty messages?
                if (nativeSendMessage == null)
                {
                    throw new ArgumentException(SR.Error_ReliableSession_EmptyMessage);
                }
                // AppTrace.TraceSource.WriteNoise("NativeReliableSession.BeginSend");
                return(this.nativeReliableSession.BeginSend(nativeSendMessage, callback));
            }
            catch
            {
                sendMessage.Unpin();
                throw;
            }
        }