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)); }
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))); }
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))); }
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; })); }
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>(); })); }
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))); }
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))); }
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))); }
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)); }
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))); }
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))); }
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)); }
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))); }
public Task CloseAsync() { ClientEntity clientEntity = this; return(TaskHelpers.CreateTask(new Func <AsyncCallback, object, IAsyncResult>(this.BeginClose), new Action <IAsyncResult>(clientEntity.EndClose))); }
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))); }
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)); }
public Task <Stream> GetStateAsync() { return(TaskHelpers.CreateTask <Stream>(new Func <AsyncCallback, object, IAsyncResult>(this.BeginGetState), new Func <IAsyncResult, Stream>(this.EndGetState))); }
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))); }
public Task RenewLockAsync() { return(TaskHelpers.CreateTask(new Func <AsyncCallback, object, IAsyncResult>(this.BeginRenewLock), new Action <IAsyncResult>(this.EndRenewLock))); }
public Task SetStateAsync(Stream stream) { return(TaskHelpers.CreateTask((AsyncCallback c, object s) => this.BeginSetState(stream, c, s), new Action <IAsyncResult>(this.EndSetState))); }
internal Task CancelScheduledMessageAsync(long sequenceNumber) { return(TaskHelpers.CreateTask((AsyncCallback c, object s) => this.BeginCancelScheduledMessage(sequenceNumber, c, s), new Action <IAsyncResult>(this.EndCancelScheduledMessage))); }