Example #1
0
 public IAsyncResult BeginConnect(string hostName, int port, AsyncCallback callback = null, object state = null)
 {
     var ar = new AsyncResult(state) { Hostname = hostName, Port = port };
     ar.Client = new TcpClient();
     ar.Client.BeginConnect(_info.ProxyHostname, _info.ProxyPort, OnConnected, ar);
     return ar;
 }
        public IAsyncResult BeginSubmitResponses(Questionnaire questionnaire, AsyncCallback callback, object asyncState)
        {
            var result = new AsyncResult<object>(callback, asyncState);
            HandleBeginSubmitResponses(result);

            return result;
        }
        public IAsyncResult BeginGetQuestionnaireTemplates(AsyncCallback callback, object asyncState)
        {
            var result = new AsyncResult<IEnumerable<QuestionnaireTemplate>>(callback, asyncState);
            HandleBeginGetQuestionnaireTemplates(result);

            return result;
        }
      public IAsyncResult BeginWrite(ReaderWriterGateCallback callback, Object state,
        AsyncCallback asyncCallback, Object asyncState) {
         AsyncResult<Object> ar = new AsyncResult<Object>(asyncCallback, asyncState);
         ReaderWriterGateReleaser releaser = new ReaderWriterGateReleaser(callback, this, false, state, ar);
         m_syncLock.Enter(true);
         switch (m_state) {
            case ReaderWriterGateStates.Free:             // If Free "RFW -> OBW, invoke, return
            case ReaderWriterGateStates.ReservedForWriter:
               m_state = ReaderWriterGateStates.OwnedByWriter;
               ThreadPool.QueueUserWorkItem(releaser.Invoke);
               break;

            case ReaderWriterGateStates.OwnedByReaders:   // If OBR | OBRAWP -> OBRAWP, queue, return
            case ReaderWriterGateStates.OwnedByReadersAndWriterPending:
               m_state = ReaderWriterGateStates.OwnedByReadersAndWriterPending;
               m_qWriteRequests.Enqueue(releaser);
               break;

            case ReaderWriterGateStates.OwnedByWriter:   // If OBW, queue, return
               m_qWriteRequests.Enqueue(releaser);
               break;
         }
         m_syncLock.Leave();
         return ar;
      }
        public IAsyncResult BeginGetQuestionnaire(AsyncCallback callback, object asyncState)
        {
            var result = new AsyncResult<Questionnaire>(callback, asyncState);
            HandleBeginGetQuestionnaire(result);

            return result;
        }
 public void Dispose()
 {
     using (asyncResult)
     {
         asyncResult = null;
     }
 }
    public void SetResult(AsyncResult asyncResult, object result)
    {
        lock (this._Lock)
        {
            List<TemporalAsyncResult> willRemovedTemporalAsyncResults = new List<TemporalAsyncResult>();
            DateTime now = DateTime.UtcNow;
            foreach(TemporalAsyncResult item in this._TemporalAsyncResults.Values)
            {
                if (now - item.TimeStamp > this._LiveTime)
                {
                    willRemovedTemporalAsyncResults.Add(item);
                }
            }
            foreach (TemporalAsyncResult item in willRemovedTemporalAsyncResults)
            {
                //AppDebug.LogEvent("AsyncResultManager.SetResult", string.Format("Delete timeout async result {0}, {1}", item.AsyncResult.Id, item.AsyncResult.MethodName), System.Diagnostics.EventLogEntryType.Information);

                this._Results.Remove(item.AsyncResult.Id);
                this._TemporalAsyncResults.Remove(item.AsyncResult.Id);
            }

            //AppDebug.LogEvent("AsyncResultManager.SetResult", string.Format("Set result of {0}, {1}", asyncResult.Id, asyncResult.MethodName), System.Diagnostics.EventLogEntryType.Information);
            this._Results.Add(asyncResult.Id, result);
            this._TemporalAsyncResults.Add(asyncResult.Id, new TemporalAsyncResult(asyncResult));
        }
    }
 public when_asyncressult_completes_on_different_thread()
 {
     asyncResult = new AsyncResult<int>(ar => Thread.VolatileWrite(ref callbackWasInvoked, 1), null);
     ThreadPool.QueueUserWorkItem(_ => asyncResult.Complete(true, ExpectedResult));
     // give the thread-pool thread time to invoke the callback
     Thread.Sleep(100);
 }
 private static void Finally(AsyncResult result, Exception currentException)
 {
     SqlWorkflowInstanceStoreAsyncResult result2 = result as SqlWorkflowInstanceStoreAsyncResult;
     try
     {
         if (result2.DependentTransaction != null)
         {
             using (result2.DependentTransaction)
             {
                 result2.DependentTransaction.Complete();
             }
         }
     }
     catch (TransactionException)
     {
         if (currentException == null)
         {
             throw;
         }
     }
     finally
     {
         result2.OnCommandCompletion();
         result2.ClearMembers();
         StoreUtilities.TraceSqlCommand(result2.sqlCommand, false);
     }
 }
 public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
 {
     read = new AsyncResult() { AsyncState = state };
     read.bytesRead = Read(buffer, offset, count);
     callback(read);
     return read;
 }
        public IAsyncResult BeginGetQuestionnaireTemplateSummary(QuestionnaireTemplate questionnaireTemplate, AsyncCallback callback, object asyncState)
        {
            var result = new AsyncResult<QuestionnaireTemplateSummary>(callback, asyncState);
            HandleBeginGetQuestionnaireTemplateSummary(result);

            return result;
        }
Example #12
0
        public void WhenCreated_ThenIsNotComplete()
        {
            var result = new AsyncResult<object>(null, this);

            Assert.IsFalse(result.IsCompleted);
            Assert.IsFalse(result.CompletedSynchronously);
        }
        public override IAsyncResult BeginDownloadXml(Uri feeduri, AsyncCallback callback)
        {
#if !WINDOWS_PHONE
            if (!IsolatedStorageFile.IsEnabled) throw new MissingFeedException("IsolatedStorage is not enabled! Cannot access files from IsolatedStorage!");
#endif


            try
            {
                using (var store = IsolatedStorageFile.GetUserStoreForApplication())
                {
                    if(!PingFeed(feeduri, store)) throw new MissingFeedException(string.Format("Could not find feed at location {0}", feeduri));

                    using (var stream = new IsolatedStorageFileStream(feeduri.OriginalString, FileMode.Open,
                                                                   FileAccess.Read, store))
                    {
                        using(var reader = new StreamReader(stream))
                        {
                            var strOutput = reader.ReadToEnd();
                            //Fake the async result
                            var result = new AsyncResult<FeedTuple>(callback, new FeedTuple { FeedContent = strOutput, FeedUri = feeduri }, true);
                            if (callback != null) callback.Invoke(result);
                            return result;
                        }
                    }
                }
            }
            catch (IsolatedStorageException ex)
            {
                throw new MissingFeedException(string.Format("Unable to open feed at {0}", feeduri), ex);
            }
        }
Example #14
0
        public void WhenCompleted_ThenESetsResult()
        {
            var result = new AsyncResult<object>(null, null);

            result.SetComplete(this, true);

            Assert.AreSame(this, result.Result);
        }
 public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
 {
     //Console.WriteLine("SMS writing " + count + " bytes.");
     write = new AsyncResult() { AsyncState = state };
     Write(buffer, offset, count);
     callback(write);
     return write;
 }
Example #16
0
        public IAsyncResult BeginReceiveMessage(AsyncCallback asyncCallback, object state)
        {
            var asyncResult = new AsyncResult<string>(asyncCallback, state);

            ReturnMessageOrBeginReceive(asyncResult, true);

            return asyncResult;
        }
 // Asynchronous version of time-consuming method (Begin part)
 public IAsyncResult BeginDoTask(AsyncCallback callback, Object state)
 {
     // Create IAsyncResult object identifying the
     // asynchronous operation
     AsyncResult<DateTime> ar = new AsyncResult<DateTime>(callback, state);
     // Use a thread pool thread to perform the operation
     ThreadPool.QueueUserWorkItem(DoTaskHelper, ar);
     return ar; // Return the IAsyncResult to the caller
 }
Example #18
0
        public void WhenCompleted_ThenExecutesCallback()
        {
            bool executed = false;
            var result = new AsyncResult<object>(ar => executed = true, null);

            result.SetComplete(null, true);

            Assert.IsTrue(executed);
        }
Example #19
0
        public void WhenCompletedSynchronouslyWithNoCallback_ThenUpdatesCompletionStatus()
        {
            var result = new AsyncResult<object>(null, null);

            result.SetComplete(null, true);

            Assert.IsTrue(result.IsCompleted);
            Assert.IsTrue(result.CompletedSynchronously);
        }
Example #20
0
		public TransferItem(byte[] buffer, int offset, int size, AsyncResult asyncResult, DataType type) {
			this.Buffer = buffer;
			this.Offset = offset;
			this.Size = size;
			this.AsyncResult = asyncResult;
			this.Transferred = 0;
			this.Type = type;
			this.OriginalSize = size;
		}
        public AccountSummaryArgument(string tradeDay, string accountIds, string rdlc, AsyncResult asyncResult, long session)
            : base(session)
        {
            this._TradeDay = tradeDay;
            this._AccountIds = accountIds;
            this._Rdlc = rdlc;

            this._AsyncResult = asyncResult;
        }
Example #22
0
 public IAsyncResult BeginAsyncAction(Action action)
 {
     var asyncresult = new AsyncResult()
                          {
                              Action =  action
                          };
     _queue.Enqueue(asyncresult);
     return asyncresult;
 }
        public AccountSummaryArgument(string fromDay, string toDay, string accountIds, string rdlc, AsyncResult asyncResult, Session session)
            : base(session)
        {
            this._FromDay = fromDay;
            this._ToDay = toDay;
            this._AccountIds = accountIds;
            this._Rdlc = rdlc;

            this._AsyncResult = asyncResult;
        }
    public TickByTickHistoryDataArgument2(Guid instrumentId, DateTime from, DateTime to,
        AsyncResult asyncResult, Session session)
        : base(session)
    {
        this._instrumentId = instrumentId;
        this._from = from;
        this._to = to;

        this._asyncResult = asyncResult;
    }
Example #25
0
    public LedgerArgument(string dateFrom, string dateTo, string IDs, string rdlc, AsyncResult asyncResult, long session)
        : base(session)
    {
        this._DateFrom = dateFrom;
        this._DateTo = dateTo;
        this._IDs = IDs;
        this._Rdlc = rdlc;

        this._AsyncResult = asyncResult;
    }
        // Asynchronous version of time-consuming method (Begin part).
        public IAsyncResult BeginFetchStockQuotes(AsyncCallback callback, Object state)
        {
            // Create IAsyncResult Object identifying the 
            // asynchronous operation.
            AsyncResult<IStockQuote> ar = new AsyncResult<IStockQuote>(callback, state);

            // Use a thread pool thread to perform the operation.
            ThreadPool.QueueUserWorkItem(FetchStockQuotesHelper, ar);

            return ar; // Return the IAsyncResult to the caller.
        }
    public ChartDataArgument(Guid instrumentId, DateTime lastDate, int count, string dataCycle, DataManager dataManager, AsyncResult asyncResult, Session session)
        : base(session)
    {
        this._instrumentId = instrumentId;
        this._lastDate = lastDate;
        this._count = count;
        this._dataCycle = dataCycle;
        this._dataManager = dataManager;

        this._asyncResult = asyncResult;
    }
        public IAsyncResult BeginGetEmailDocuments(AsyncCallback callback, object userState)
        {
            var asyncResult = new AsyncResult<IEnumerable<EmailDocument>>(callback, userState);
            ThreadPool.QueueUserWorkItem(
                o =>
                {
                    asyncResult.SetComplete(new ReadOnlyCollection<EmailDocument>(this.emailDocuments), false);
                });

            return asyncResult;
        }
    public ChartDataArgument2(Guid instrumentId, String dataCycle, DateTime from, DateTime to,
            AsyncResult asyncResult, Session session)
        : base(session)
    {
        this._instrumentId = instrumentId;
        this._dataCycle = dataCycle;
        this._from = from;
        this._to = to;

        this._asyncResult = asyncResult;
    }
        public AsyncResult CalculateOpticalFlow(CvPoint2D32f[] corners0)
        {
            var r = new AsyncResult();
            r.prevTime = _prevTime = _currTime;
            r.currTime = _currTime = Time.time;
            r.corners0 = corners0;
            r.nCorners = corners0.Length;

            ThreadPool.QueueUserWorkItem(_CalculateOpticalFlow, r);
            return r;
        }
 public static new void End(IAsyncResult result)
 {
     AsyncResult.End <CloseEntityCollectionAsyncResult>(result);
 }
Example #32
0
 public ASYNCSTATE DeleteCommonDataAsync(ulong uniqueId = 0 /* Metadata: 0x00632246 */, AsyncResultCB callback = null, IntPtr pNgsFacade = default, int timeOut = 0 /* Metadata: 0x0063224E */) => default;                                                                                                                                                                                                                     // 0x00DB4B60-0x00DB4C70
 private ASYNCSTATE DeleteCommonDataAsync_(AsyncResult asyncResult, CORE_ARG param) => default;                                                                                                                                                                                                                                                                                                                                 // 0x00DB4C80-0x00DB4E20
Example #33
0
 public ASYNCSTATE GetStatsAsync(uint category, RankingOrderParam param, NexPlugin.Ranking.StatsFlag flags, NexPlugin.Ranking.GetStatsCB callback = null, IntPtr pNgsFacade = default, int timeOut = 0 /* Metadata: 0x00632256 */) => default;                                                                                                                                                                                  // 0x00DB4F20-0x00DB5050
 private ASYNCSTATE GetStatsAsync_(AsyncResult asyncResult, CORE_ARG param) => default;                                                                                                                                                                                                                                                                                                                                         // 0x00DB5060-0x00DB5210
Example #34
0
 public ASYNCSTATE GetCachedTopXRankingsAsync(List <uint> categorieList, List <RankingOrderParam> paramList, NexPlugin.Ranking.GetCachedTopXRankingsCB callback = null, IntPtr pNgsFacade = default, int timeOut = 0 /* Metadata: 0x0063227A */) => default;                                                                                                                                                                    // 0x00DB5B70-0x00DB5C90
 private ASYNCSTATE GetCachedTopXRankingsAsync_(AsyncResult asyncResult, CORE_ARG param) => default;                                                                                                                                                                                                                                                                                                                            // 0x00DB5C90-0x00DB5F20
 public static void End(IAsyncResult result)
 {
     AsyncResult.End <CloseAsyncResult>(result);
 }
        public static ResolveMatchesMessageCD1 End(IAsyncResult result)
        {
            ResolveRequestResponseCD1AsyncResult thisPtr = AsyncResult.End <ResolveRequestResponseCD1AsyncResult>(result);

            return(thisPtr.End());
        }
Example #37
0
 public static void End(IAsyncResult result)
 {
     AsyncResult.End <OnWriteBodyContentsAsyncResult>(result);
 }
 EndpointDiscoveryMetadata11[] IServiceCatalog.EndListServices(IAsyncResult result)
 {
     return(AsyncResult.End <EndpointDiscoveryMetadata11[]>(result));
 }
Example #39
0
 public static void End(IAsyncResult result)
 {
     AsyncResult.End <SerializeBodyContentsAsyncResult>(result);
 }
 protected override void OnEndOfflineAnnouncement(IAsyncResult result)
 {
     AsyncResult.End(result);
 }
 protected override EndpointDiscoveryMetadata OnEndResolve(IAsyncResult result)
 {
     return(AsyncResult.End <EndpointDiscoveryMetadata>(result));
 }
Example #42
0
 public static void End(IAsyncResult result)
 {
     AsyncResult.End <HelloOperationCD1AsyncResult>(result);
 }
 public static SqlDataReader End(IAsyncResult result)
 {
     return(AsyncResult.End <SqlCommandAsyncResult>(result).sqlDataReader);
 }
Example #44
0
 public static void End(IAsyncResult result)
 {
     AsyncResult.End <FlushBufferAsyncResult>(result);
 }
Example #45
0
 public static void End(IAsyncResult result)
 {
     AsyncResult.End <CloseCommunicationAsyncResult>(result);
 }
Example #46
0
 public static void End(IAsyncResult result)
 {
     AsyncResult.End <OpenCollectionAsyncResult>(result);
 }
Example #47
0
 public static Microsoft.ServiceBus.Channels.IConnection End(IAsyncResult result, out SecurityMessageProperty remoteSecurity)
 {
     Microsoft.ServiceBus.Channels.StreamedFramingRequestChannel.StreamedConnectionPoolHelper.SendPreambleAsyncResult sendPreambleAsyncResult = AsyncResult.End <Microsoft.ServiceBus.Channels.StreamedFramingRequestChannel.StreamedConnectionPoolHelper.SendPreambleAsyncResult>(result);
     remoteSecurity = sendPreambleAsyncResult.remoteSecurity;
     return(sendPreambleAsyncResult.connection);
 }
 public static new void End(IAsyncResult result)
 {
     AsyncResult.End <BatchManager <TItem> .BatchedObjectsAsyncResult>(result);
 }
Example #49
0
 public static void End(IAsyncResult result)
 {
     AsyncResult.End <WriteBytesAsyncResult>(result);
 }
 public static new void End(IAsyncResult result)
 {
     AsyncResult.End <BatchManager <TItem> .PerformFlushAsyncResult>(result);
 }
Example #51
0
 public static new T End(IAsyncResult result)
 {
     return(AsyncResult.End <Microsoft.ServiceBus.Channels.SynchronizedMessageSource.SynchronizedAsyncResult <T> >(result).returnValue);
 }
Example #52
0
 public static new AmqpMessage End(IAsyncResult result)
 {
     return(AsyncResult.End <RequestResponseAmqpLink.RequestAsyncResult>(result).response);
 }
Example #53
0
 public ASYNCSTATE ChangeAttributesAsync(RankingChangeAttributesParam param, ulong uniqueId = 0 /* Metadata: 0x00632266 */, AsyncResultCB callback = null, IntPtr pNgsFacade = default, int timeOut = 0 /* Metadata: 0x0063226E */) => default;                                                                                                                                                                                 // 0x00DB5370-0x00DB5490
 private ASYNCSTATE ChangeAttributesAsync_(AsyncResult asyncResult, CORE_ARG param) => default;                                                                                                                                                                                                                                                                                                                                 // 0x00DB5490-0x00DB5700
 private void PerformApiRequest <TReturn>(AsyncResult result, IChinaAlibabaApi api, IChinaAlibabaApiArguments args, Action <Exception, TReturn> callback)
 {
     this.PerformApiRequest(result, api, args, (error, content) => {
         this.ProcessReturnValue <TReturn>(error, content, callback);
     });
 }
Example #55
0
        /// <summary>
        /// Asynchronously discover UPnP-enabled gateways on the local network. This method must be called before
        /// attempting any other operation.
        /// </summary>
        /// <param name="callback">An optional callback invoked when the operation is complete.</param>
        /// <param name="state">An optional state parameter supplied to the callback.</param>
        /// <returns>Returns an object which must be passed to EndDiscover.</returns>
        public static IAsyncResult BeginDiscover(AsyncCallback callback = null, object state = null)
        {
            var sock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

            sock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, 1);
            var endpoint = new IPEndPoint(IPAddress.Broadcast, 1900);

            byte[] outBuf = Encoding.ASCII.GetBytes(BroadcastPacket);
            byte[] inBuf  = new Byte[4096];

            var ar = new AsyncResult {
                AsyncWaitHandle = new ManualResetEvent(false), AsyncState = state
            };

            ThreadPool.QueueUserWorkItem((o) =>
            {
                int tries = MaxTries;
                while (--tries >= 0)
                {
                    try
                    {
                        sock.SendTo(outBuf, endpoint);
                        sock.ReceiveTimeout = DiscoverTimeout;
                        while (true)
                        {
                            int length  = sock.Receive(inBuf);
                            string data = Encoding.ASCII.GetString(inBuf, 0, length).ToLowerInvariant();

                            var match = ResponseLocation.Match(data);
                            if (match.Success && match.Groups["location"].Success)
                            {
                                System.Diagnostics.Debug.WriteLine("Found UPnP device at " + match.Groups["location"]);
                                string controlUrl = GetServiceUrl(match.Groups["location"].Value);
                                if (!string.IsNullOrEmpty(controlUrl))
                                {
                                    _controlUrl = controlUrl;
                                    System.Diagnostics.Debug.WriteLine("Found control URL at " + _controlUrl);
                                    ar.IsSuccessful = true;
                                    break;
                                }
                                else
                                {
                                    continue;
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        // ignore timeout exceptions
                        if (!(ex is SocketException && ((SocketException)ex).ErrorCode == 10060))
                        {
                            System.Diagnostics.Debug.WriteLine(ex.ToString());
                        }
                    }
                }

                ((ManualResetEvent)ar.AsyncWaitHandle).Set();
                if (callback != null)
                {
                    callback(ar);
                }
            }, null);
            return(ar);
        }
            protected override IEnumerator <IteratorAsyncResult <TokenProviderHelper.TokenRequestAsyncResult> .AsyncStep> GetAsyncSteps()
            {
                try
                {
                    StringBuilder stringBuilder    = new StringBuilder();
                    CultureInfo   invariantCulture = CultureInfo.InvariantCulture;
                    object[]      objArray         = new object[] { "wrap_scope", HttpUtility.UrlEncode(this.appliesTo) };
                    stringBuilder.AppendFormat(invariantCulture, "{0}={1}", objArray);
                    stringBuilder.Append('&');
                    CultureInfo cultureInfo = CultureInfo.InvariantCulture;
                    object[]    objArray1   = new object[] { "wrap_assertion_format", this.simpleAuthAssertionFormat };
                    stringBuilder.AppendFormat(cultureInfo, "{0}={1}", objArray1);
                    stringBuilder.Append('&');
                    CultureInfo invariantCulture1 = CultureInfo.InvariantCulture;
                    object[]    objArray2         = new object[] { "wrap_assertion", HttpUtility.UrlEncode(this.requestToken) };
                    stringBuilder.AppendFormat(invariantCulture1, "{0}={1}", objArray2);
                    this.body    = Encoding.UTF8.GetBytes(stringBuilder.ToString());
                    this.request = (HttpWebRequest)WebRequest.Create(this.requestUri);
                    this.request.ServicePoint.MaxIdleTime     = Constants.ServicePointMaxIdleTimeMilliSeconds;
                    this.request.AllowAutoRedirect            = true;
                    this.request.MaximumAutomaticRedirections = 1;
                    this.request.Method        = "POST";
                    this.request.ContentType   = "application/x-www-form-urlencoded";
                    this.request.ContentLength = (long)((int)this.body.Length);
                    try
                    {
                        HttpWebRequest num      = this.request;
                        TimeSpan       timeSpan = base.RemainingTime();
                        num.Timeout = Convert.ToInt32(timeSpan.TotalMilliseconds, CultureInfo.InvariantCulture);
                    }
                    catch (OverflowException overflowException)
                    {
                        throw new ArgumentException(SRClient.TimeoutExceeded, overflowException);
                    }
                }
                catch (ArgumentException argumentException)
                {
                    base.Complete(this.ConvertException(argumentException));
                    goto Label0;
                }
                try
                {
                    this.requestCancelTimer = new IOThreadTimer(TokenProviderHelper.TokenRequestAsyncResult.onCancelTimer, this, true);
                    try
                    {
                        TimeSpan timeSpan1 = base.RemainingTime();
                        if (timeSpan1 > TimeSpan.Zero)
                        {
                            TokenProviderHelper.TokenRequestAsyncResult tokenRequestAsyncResult = this;
                            IteratorAsyncResult <TokenProviderHelper.TokenRequestAsyncResult> .BeginCall beginCall = (TokenProviderHelper.TokenRequestAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => {
                                IAsyncResult asyncResult = thisPtr.request.BeginGetRequestStream(c, s);
                                thisPtr.requestCancelTimer.Set(timeSpan1);
                                return(asyncResult);
                            };
                            yield return(tokenRequestAsyncResult.CallAsync(beginCall, (TokenProviderHelper.TokenRequestAsyncResult thisPtr, IAsyncResult r) => thisPtr.requestStream = thisPtr.request.EndGetRequestStream(r), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Continue));

                            if (base.LastAsyncStepException == null)
                            {
                                TokenProviderHelper.TokenRequestAsyncResult tokenRequestAsyncResult1 = this;
                                IteratorAsyncResult <TokenProviderHelper.TokenRequestAsyncResult> .BeginCall beginCall1 = (TokenProviderHelper.TokenRequestAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.requestStream.BeginWrite(thisPtr.body, 0, (int)thisPtr.body.Length, c, s);
                                yield return(tokenRequestAsyncResult1.CallAsync(beginCall1, (TokenProviderHelper.TokenRequestAsyncResult thisPtr, IAsyncResult r) => thisPtr.requestStream.EndWrite(r), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Continue));

                                if (base.LastAsyncStepException == null)
                                {
                                    goto Label1;
                                }
                                base.Complete(this.ConvertException(base.LastAsyncStepException));
                                goto Label0;
                            }
                            else
                            {
                                base.Complete(this.ConvertException(base.LastAsyncStepException));
                                goto Label0;
                            }
                        }
                        else
                        {
                            base.Complete(new TimeoutException(SRClient.OperationRequestTimedOut(base.OriginalTimeout)));
                            goto Label0;
                        }
                    }
                    finally
                    {
                        if (this.requestStream != null)
                        {
                            this.requestStream.Dispose();
                        }
                        this.requestCancelTimer.Cancel();
                    }
Label1:
                    TimeSpan timeSpan2 = base.RemainingTime();
                    if (timeSpan2 > TimeSpan.Zero)
                    {
                        TokenProviderHelper.TokenRequestAsyncResult tokenRequestAsyncResult2 = this;
                        IteratorAsyncResult <TokenProviderHelper.TokenRequestAsyncResult> .BeginCall beginCall2 = (TokenProviderHelper.TokenRequestAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => {
                            IAsyncResult asyncResult = thisPtr.request.BeginGetResponse(c, s);
                            thisPtr.requestCancelTimer.Set(timeSpan2);
                            return(asyncResult);
                        };
                        yield return(tokenRequestAsyncResult2.CallAsync(beginCall2, (TokenProviderHelper.TokenRequestAsyncResult thisPtr, IAsyncResult r) => thisPtr.response = (HttpWebResponse)thisPtr.request.EndGetResponse(r), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Continue));

                        if (base.LastAsyncStepException == null)
                        {
                            TokenProviderHelper.TokenRequestAsyncResult tokenRequestAsyncResult3 = this;
                            Stream responseStream = this.response.GetResponseStream();
                            Stream stream         = responseStream;
                            tokenRequestAsyncResult3.sourceStream = responseStream;
                            using (stream)
                            {
                                TokenProviderHelper.TokenRequestAsyncResult tokenRequestAsyncResult4 = this;
                                MemoryStream memoryStream  = new MemoryStream();
                                MemoryStream memoryStream1 = memoryStream;
                                tokenRequestAsyncResult4.tmpStream = memoryStream;
                                using (memoryStream1)
                                {
                                    TokenProviderHelper.TokenRequestAsyncResult tokenRequestAsyncResult5 = this;
                                    IteratorAsyncResult <TokenProviderHelper.TokenRequestAsyncResult> .BeginCall streamReaderAsyncResult = (TokenProviderHelper.TokenRequestAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => new TokenProviderHelper.StreamReaderAsyncResult(thisPtr.sourceStream, thisPtr.tmpStream, t, c, s);
                                    yield return(tokenRequestAsyncResult5.CallAsync(streamReaderAsyncResult, (TokenProviderHelper.TokenRequestAsyncResult thisPtr, IAsyncResult r) => AsyncResult <TokenProviderHelper.StreamReaderAsyncResult> .End(r), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Continue));

                                    if (base.LastAsyncStepException == null)
                                    {
                                        try
                                        {
                                            this.tmpStream.Position = (long)0;
                                            using (StreamReader streamReader = new StreamReader(this.tmpStream, Encoding.UTF8))
                                            {
                                                string end = streamReader.ReadToEnd();
                                                TokenProviderHelper.ExtractAccessToken(end, out this.accessToken, out this.expiresIn, out this.audience);
                                            }
                                        }
                                        catch (Exception exception1)
                                        {
                                            Exception exception = exception1;
                                            if (Fx.IsFatal(exception))
                                            {
                                                throw;
                                            }
                                            base.Complete(this.ConvertException(exception));
                                        }
                                    }
                                    else
                                    {
                                        base.Complete(this.ConvertException(base.LastAsyncStepException));
                                    }
                                }
                            }
                        }
                        else
                        {
                            base.Complete(this.ConvertException(base.LastAsyncStepException));
                        }
                    }
                    else
                    {
                        base.Complete(new TimeoutException(SRClient.OperationRequestTimedOut(base.OriginalTimeout)));
                    }
                }
                finally
                {
                    if (this.requestCancelTimer != null)
                    {
                        this.requestCancelTimer.Cancel();
                    }
                }
Label0:
                yield break;
            }
Example #57
0
 public ASYNCSTATE GetCommonDataAsync(ulong uniqueId = 0 /* Metadata: 0x0063223A */, NexPlugin.Ranking.GetCommonDataCB callback = null, IntPtr pNgsFacade = default, int timeOut = 0 /* Metadata: 0x00632242 */) => default;                                                                                                                                                                                                    // 0x00DB4870-0x00DB4980
 private ASYNCSTATE GetCommonDataAsync_(AsyncResult asyncResult, CORE_ARG param) => default;                                                                                                                                                                                                                                                                                                                                    // 0x00DB4990-0x00DB4B60
        public static SqlDataReader End(IAsyncResult result)
        {
            SqlCommandAsyncResult SqlCommandAsyncResult = AsyncResult.End <SqlCommandAsyncResult>(result);

            return(SqlCommandAsyncResult.sqlDataReader);
        }
 protected override void OnEndFind(IAsyncResult result)
 {
     AsyncResult.End(result);
 }
Example #60
0
 public static void End(IAsyncResult result)
 {
     AsyncResult.End <SerializeAsyncResult>(result);
 }