Amqp.TaskExtensions.GetTransactionalStateAsync C# (CSharp) Method

GetTransactionalStateAsync() static private method

static private GetTransactionalStateAsync ( SenderLink sender ) : Task
sender SenderLink
return Task
        static async Task<DeliveryState> GetTransactionalStateAsync(SenderLink sender)
        {
            return await Amqp.Transactions.ResourceManager.GetTransactionalStateAsync(sender);
        }
#endif

Usage Example

Beispiel #1
0
        /// <summary>
        /// Sends a message asynchronously.
        /// </summary>
        /// <param name="sender">The link.</param>
        /// <param name="message">The message.</param>
        /// <returns></returns>
        public static async Task SendAsync(this SenderLink sender, Message message)
        {
            DeliveryState txnState = null;

#if NETFX || NETFX40
            txnState = await TaskExtensions.GetTransactionalStateAsync(sender);
#endif
            TaskCompletionSource <object> tcs = new TaskCompletionSource <object>();
            sender.Send(
                message,
                txnState,
                (m, o, s) =>
            {
                var t = (TaskCompletionSource <object>)s;
                if (o.Descriptor.Code == Codec.Accepted.Code)
                {
                    t.SetResult(null);
                }
                else if (o.Descriptor.Code == Codec.Rejected.Code)
                {
                    t.SetException(new AmqpException(((Rejected)o).Error));
                }
                else
                {
                    t.SetException(new AmqpException(ErrorCode.InternalError, o.Descriptor.Name));
                }
            },
                tcs);

            await tcs.Task;
        }
All Usage Examples Of Amqp.TaskExtensions::GetTransactionalStateAsync