Пример #1
0
 public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
 {
     return(TaskHelpers.CreateTask(
                (c, s) => this.BeginWrite(buffer, offset, count, c, s),
                (a) => this.EndWrite(a),
                this));
 }
Пример #2
0
 private Task StartAsync()
 {
     if (Interlocked.CompareExchange(ref this.isStarted, 1, 0) != 0)
     {
         throw new InvalidOperationException("EventHubDispatcher has already started");
     }
     return(TaskHelpers.CreateTask <EventProcessorLifecycleManager.EventProcessorInitializeAsyncResult>((AsyncCallback c, object s) => EventProcessorLifecycleManager.EventProcessorInitializeAsyncResult.Begin(this, this.lease, c, s), (IAsyncResult r) => AsyncResult <EventProcessorLifecycleManager.EventProcessorInitializeAsyncResult> .End(r)));
 }
Пример #3
0
 public Task UnregisterProcessorAsync(CloseReason reason)
 {
     if (Interlocked.CompareExchange(ref this.isStarted, 0, 1) != 1)
     {
         return(TaskHelpers.GetCompletedTask <object>(null));
     }
     return(TaskHelpers.CreateTask <EventProcessorLifecycleManager.EventProcessorShutdownAsyncResult>((AsyncCallback c, object s) => EventProcessorLifecycleManager.EventProcessorShutdownAsyncResult.Begin(this, this.eventHubReceiver, this.processor, this.context, reason, this.dispatchTask, c, s), (IAsyncResult r) => AsyncResult <EventProcessorLifecycleManager.EventProcessorShutdownAsyncResult> .End(r)));
 }
Пример #4
0
 public Task <IEnumerable <EventData> > ReceiveAsync(int maxCount, TimeSpan waitTime)
 {
     this.ThrowIfReceiverNull("Receive");
     return(TaskHelpers.CreateTask <IEnumerable <EventData> >((AsyncCallback callback, object o) => this.InternalReceiver.BeginTryReceiveEventData(null, maxCount, waitTime, callback, o), (IAsyncResult result) => {
         IEnumerable <EventData> eventDatas;
         if (!this.InternalReceiver.EndTryReceiveEventData(result, out eventDatas))
         {
             return Enumerable.Empty <EventData>();
         }
         return eventDatas;
     }));
 }
Пример #5
0
 public Task <EventData> ReceiveAsync(TimeSpan waitTime)
 {
     this.ThrowIfReceiverNull("Receive");
     return(TaskHelpers.CreateTask <EventData>((AsyncCallback callback, object o) => this.InternalReceiver.BeginTryReceiveEventData(null, 1, waitTime, callback, o), (IAsyncResult result) => {
         IEnumerable <EventData> eventDatas;
         if (!this.InternalReceiver.EndTryReceiveEventData(result, out eventDatas))
         {
             return null;
         }
         return eventDatas.FirstOrDefault <EventData>();
     }));
 }
Пример #6
0
 internal Task CheckpointAsync(EventData data)
 {
     this.ThrowIfReceiverNull("Receive");
     if (data == null)
     {
         throw Fx.Exception.ArgumentNull("data");
     }
     if (this.InternalReceiver.Mode == ReceiveMode.ReceiveAndDelete)
     {
         throw FxTrace.Exception.AsError(new InvalidOperationException(SRClient.CannotCheckpointWithCurrentConsumerGroup), null);
     }
     return(TaskHelpers.CreateTask((AsyncCallback callback, object o) => this.InternalReceiver.BeginCheckpoint(null, data.DeliveryTag, callback, o), (IAsyncResult result) => this.InternalReceiver.EndCheckpoint(result)));
 }
Пример #7
0
 public Task <NotificationOutcome> SendNotificationAsync(Notification notification, bool testSend, string tagExpression)
 {
     return(TaskHelpers.CreateTask <NotificationOutcome>((AsyncCallback c, object s) => this.BeginSendNotification(notification, testSend, tagExpression, c, s), new Func <IAsyncResult, NotificationOutcome>(this.EndSendNotification)));
 }
Пример #8
0
 public override Task <EventHubRuntimeInformation> GetRuntimeInformationAsync()
 {
     return(TaskHelpers.CreateTask <EventHubRuntimeInformation>((AsyncCallback c, object s) => this.BeginGetRuntimeInfo(this.OperationTimeout, c, s), (IAsyncResult r) => this.EndGetRuntimeInfo(r)));
 }
 public Task <BrokeredMessage> ReceiveAsync()
 {
     return(TaskHelpers.CreateTask <BrokeredMessage>(new Func <AsyncCallback, object, IAsyncResult>(this.BeginReceive), new Func <IAsyncResult, BrokeredMessage>(this.EndReceive)));
 }
Пример #10
0
 public Task SendAsync(EventData data)
 {
     this.ThrowIfSenderNull("Send");
     return(TaskHelpers.CreateTask((AsyncCallback c, object s) => this.InternalSender.BeginSendEventData(null, new EventData[] { data }, this.OperationTimeout, c, s), new Action <IAsyncResult>(this.InternalSender.EndSendEventData)));
 }
 public Task <BrokeredMessage> ReceiveAsync(TimeSpan serverWaitTime)
 {
     return(TaskHelpers.CreateTask <BrokeredMessage>((AsyncCallback c, object s) => this.BeginReceive(serverWaitTime, c, s), new Func <IAsyncResult, BrokeredMessage>(this.EndReceive)));
 }
 public Task RegisterSessionHandlerFactoryAsync(IMessageSessionAsyncHandlerFactory factory, SessionHandlerOptions options)
 {
     return(TaskHelpers.CreateTask((AsyncCallback c, object s) => this.BeginRegisterSessionHandler(factory, options, c, s), (IAsyncResult r) => this.EndRegisterSessionHandler(r)));
 }
 public Task <EventHubReceiver> CreateReceiverAsync(string partitionId, string startingOffset, bool offsetInclusive)
 {
     base.ThrowIfDisposed();
     return(TaskHelpers.CreateTask <EventHubConsumerGroup, EventHubReceiver>((EventHubConsumerGroup thisPtr, AsyncCallback c, object s) => (new EventHubConsumerGroup.CreateReceiverAsyncResult(thisPtr, partitionId, startingOffset, null, null, offsetInclusive, thisPtr.OperationTimeout, c, s)).Start(), (EventHubConsumerGroup thisPtr, IAsyncResult r) => AsyncResult <EventHubConsumerGroup.CreateReceiverAsyncResult> .End(r).Receiver, this));
 }
Пример #14
0
 public Task <ScheduledNotification> ScheduleNotificationAsync(Notification notification, DateTimeOffset scheduledTime, string tagExpression)
 {
     return(TaskHelpers.CreateTask <ScheduledNotification>((AsyncCallback c, object s) => this.BeginScheduleNotification(notification, scheduledTime, tagExpression, c, s), new Func <IAsyncResult, ScheduledNotification>(this.EndScheduleNotification)));
 }
Пример #15
0
 public Task <string> GetWebTokenAsync(string appliesTo, string action, bool bypassCache, TimeSpan timeout)
 {
     return(TaskHelpers.CreateTask <string>((AsyncCallback c, object s) => this.BeginGetWebToken(appliesTo, action, bypassCache, timeout, c, s), new Func <IAsyncResult, string>(this.EndGetWebToken)));
 }
Пример #16
0
 public Task <RegistrationCounts> GetRegistrationCountsByTagAsync(string tag)
 {
     return(TaskHelpers.CreateTask <RegistrationCounts>((AsyncCallback c, object s) => new GetRegistrationCountsAsyncResult(this, tag, c, s), (IAsyncResult r) => AsyncResult <GetRegistrationCountsAsyncResult> .End(r).Result));
 }
Пример #17
0
 internal Task <NotificationDetails> GetNotificationAsync(string notificationId)
 {
     return(TaskHelpers.CreateTask <NotificationDetails>((AsyncCallback c, object s) => new GetNotificationAsyncResult(this, notificationId, c, s), (IAsyncResult r) => AsyncResult <GetNotificationAsyncResult> .End(r).Result));
 }
 public Task SendBatchAsync(IEnumerable <BrokeredMessage> messages)
 {
     return(TaskHelpers.CreateTask((AsyncCallback c, object s) => this.BeginSendBatch(messages, c, s), new Action <IAsyncResult>(this.EndSendBatch)));
 }
 public Task SendAsync(BrokeredMessage message)
 {
     return(TaskHelpers.CreateTask((AsyncCallback c, object s) => this.BeginSend(message, c, s), new Action <IAsyncResult>(this.EndSend)));
 }
 public Task <IEnumerable <BrokeredMessage> > ReceiveBatchAsync(int messageCount, TimeSpan serverWaitTime)
 {
     return(TaskHelpers.CreateTask <IEnumerable <BrokeredMessage> >((AsyncCallback c, object s) => this.BeginReceiveBatch(messageCount, serverWaitTime, c, s), new Func <IAsyncResult, IEnumerable <BrokeredMessage> >(this.EndReceiveBatch)));
 }
Пример #21
0
        public Task CloseAsync()
        {
            ClientEntity clientEntity = this;

            return(TaskHelpers.CreateTask(new Func <AsyncCallback, object, IAsyncResult>(this.BeginClose), new Action <IAsyncResult>(clientEntity.EndClose)));
        }
Пример #22
0
 public Task <IEnumerable <RegistrationDescription> > UpdateRegistrationsWithNewPnsHandleAsync(string oldPnsHandle, string newPnsHandle)
 {
     return(TaskHelpers.CreateTask <IEnumerable <RegistrationDescription> >((AsyncCallback c, object s) => this.BeginUpdateRegistrationsWithNewPnsHandle(oldPnsHandle, newPnsHandle, c, s), new Func <IAsyncResult, IEnumerable <RegistrationDescription> >(this.EndUpdateRegistrationsWithNewPnsHandle)));
 }
 public Task RegisterSessionHandlerAsync(Type handlerType)
 {
     return(TaskHelpers.CreateTask((AsyncCallback c, object s) => this.BeginRegisterSessionHandler(handlerType, null, c, s), (IAsyncResult r) => this.EndRegisterSessionHandler(r)));
 }
Пример #24
0
 public Task CancelScheduledNotificationAsync(string scheduledNotificationId)
 {
     return(TaskHelpers.CreateTask((AsyncCallback c, object s) => this.BeginCancelScheduledNotification(scheduledNotificationId, c, s), new Action <IAsyncResult>(this.EndCancelScheduledNotification)));
 }
 public Task <EventHubReceiver> CreateReceiverAsync(string partitionId, DateTime startingDateTimeUtc, long epoch)
 {
     base.ThrowIfDisposed();
     return(TaskHelpers.CreateTask <EventHubConsumerGroup, EventHubReceiver>((EventHubConsumerGroup thisPtr, AsyncCallback c, object s) => (new EventHubConsumerGroup.CreateReceiverAsyncResult(thisPtr, partitionId, null, new DateTime?(startingDateTimeUtc), new long?(epoch), thisPtr.OperationTimeout, c, s)).Start(), (EventHubConsumerGroup thisPtr, IAsyncResult r) => AsyncResult <EventHubConsumerGroup.CreateReceiverAsyncResult> .End(r).Receiver, this));
 }
Пример #26
0
 public Task <Stream> GetStateAsync()
 {
     return(TaskHelpers.CreateTask <Stream>(new Func <AsyncCallback, object, IAsyncResult>(this.BeginGetState), new Func <IAsyncResult, Stream>(this.EndGetState)));
 }
Пример #27
0
 public Task SendBatchAsync(IEnumerable <EventData> eventDataList)
 {
     this.ThrowIfSenderNull("SendBatchAsync");
     return(TaskHelpers.CreateTask((AsyncCallback c, object s) => this.InternalSender.BeginSendEventData(null, eventDataList, this.OperationTimeout, c, s), new Action <IAsyncResult>(this.InternalSender.EndSendEventData)));
 }
Пример #28
0
 public Task RenewLockAsync()
 {
     return(TaskHelpers.CreateTask(new Func <AsyncCallback, object, IAsyncResult>(this.BeginRenewLock), new Action <IAsyncResult>(this.EndRenewLock)));
 }
Пример #29
0
 public Task SetStateAsync(Stream stream)
 {
     return(TaskHelpers.CreateTask((AsyncCallback c, object s) => this.BeginSetState(stream, c, s), new Action <IAsyncResult>(this.EndSetState)));
 }
Пример #30
0
 internal Task CancelScheduledMessageAsync(long sequenceNumber)
 {
     return(TaskHelpers.CreateTask((AsyncCallback c, object s) => this.BeginCancelScheduledMessage(sequenceNumber, c, s), new Action <IAsyncResult>(this.EndCancelScheduledMessage)));
 }