示例#1
0
 private static void Callback(IAsyncResult result)
 {
     if (result.CompletedSynchronously)
     {
         return;
     }
     Microsoft.ServiceBus.Channels.OpenCollectionAsyncResult.CallbackState asyncState = (Microsoft.ServiceBus.Channels.OpenCollectionAsyncResult.CallbackState)result.AsyncState;
     asyncState.Result.CompleteOpen(asyncState.Instance, result);
 }
示例#2
0
        public OpenCollectionAsyncResult(TimeSpan timeout, AsyncCallback otherCallback, object state, IList <ICommunicationObject> collection) : base(otherCallback, state)
        {
            IAsyncResult asyncResult;

            this.timeoutHelper = new Microsoft.ServiceBus.Common.TimeoutHelper(timeout);
            this.count         = collection.Count;
            if (this.count == 0)
            {
                base.Complete(true);
                return;
            }
            foreach (ICommunicationObject communicationObject in collection)
            {
                if (communicationObject == null)
                {
                    this.Decrement(true);
                }
                else if (this.exception == null)
                {
                    Microsoft.ServiceBus.Channels.OpenCollectionAsyncResult.CallbackState callbackState = new Microsoft.ServiceBus.Channels.OpenCollectionAsyncResult.CallbackState(this, communicationObject);
                    try
                    {
                        asyncResult = communicationObject.BeginOpen(this.timeoutHelper.RemainingTime(), Microsoft.ServiceBus.Channels.OpenCollectionAsyncResult.nestedCallback, callbackState);
                    }
                    catch (Exception exception1)
                    {
                        Exception exception = exception1;
                        if (Fx.IsFatal(exception))
                        {
                            throw;
                        }
                        this.Decrement(true, exception);
                        communicationObject.Abort();
                        continue;
                    }
                    if (!asyncResult.CompletedSynchronously)
                    {
                        continue;
                    }
                    this.CompleteOpen(communicationObject, asyncResult);
                }
                else
                {
                    return;
                }
            }
        }