Example #1
0
 public void Abort()
 {
     if (asyncHandle != null)
     {
         asyncHandle.Abort();
     }
 }
Example #2
0
 public void Abort()
 {
     try
     {
         _handle.Abort();
     }
     catch (Exception) { }
 }
Example #3
0
 public void Stop()
 {
     m_Running = false;
     ClearTexture();
     if (m_Handle != null)
     {
         m_Handle.Abort();
     }
 }
Example #4
0
 private void SynchronizedCancel()
 {
     if (!Cancelled)
     {
         Cancelled = true;
         if (_killSwitch != null)
         {
             _killSwitch.Abort();
         }
     }
 }
 private void SynchronizedCancel()
 {
     if (!Cancelled)
     {
         Cancelled = true;
         if (_killSwitch != null)
         {
             System.Console.WriteLine("FLIPPING KILL SWITCH RIGHT MEOW.");
             _killSwitch.Abort();
             System.Console.WriteLine("FLIPPED.");
         }
     }
 }
Example #6
0
 private void HttpGetResponse(IRestResponse resp, RestRequestAsyncHandle handle)
 {
     if (resp.StatusCode == HttpStatusCode.OK)
     {
         DocParser doc   = new DocParser();
         var       sinfo = doc.GetStackInfo(resp.Content);
         if (sinfo != null)
         {
             stock = new Stock()
             {
                 Num = Sno, Info = sinfo
             };
             IsSuccess = true;
         }
     }
     handle.Abort();
 }
        public static async Task <IRestResponse <T> > ExecuteTaskAsync <T>(this RestClient client, IRestRequest request, CancellationToken token)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }

            TaskCompletionSource <IRestResponse <T> > taskCompletionSource = new TaskCompletionSource <IRestResponse <T> >();

            try
            {
                RestRequestAsyncHandle async = client.ExecuteAsync <T>(
                    request,
                    (response, _) =>
                {
                    if (token.IsCancellationRequested)
                    {
                        taskCompletionSource.TrySetCanceled();
                    }
                    // Don't run TrySetException, since we should set Error properties and swallow exceptions
                    // to be consistent with sync methods
                    else
                    {
                        taskCompletionSource.TrySetResult(response);
                    }
                });


                CancellationTokenRegistration registration =

                    token.Register(() =>
                {
                    async.Abort();
                    taskCompletionSource.TrySetCanceled();
                });


                taskCompletionSource.Task.ContinueWith(t => registration.Dispose(), token);
            }
            catch (Exception ex)
            {
                taskCompletionSource.TrySetException(ex);
            }

            return(await taskCompletionSource.Task);
        }
Example #8
0
        /// <summary>
        /// 重新读取数据
        /// </summary>
        private void LoadDnsRecord()
        {
            if (null == mTenCloudDns)
            {
                return;
            }
            //如果有未完成的请求, 先中止
            AsyncHandle?.Abort();

            AsyncHandle = mTenCloudDns.queryRecordList <DnsRecordResult>(null, null, response =>
            {
                Dispatcher.Invoke(() =>
                {
                    //更新表格数据
                    if (null != response.Data.data)
                    {
                        DnsRecordList = response.Data.data.records;
                        DnsRecordDataGrid.ItemsSource = DnsRecordList;
                    }
                });
            });
        }
 public void OnNavigatedFrom(NavigationContext navigationContext)
 {
     _serverUpdateActionHandle?.Abort();
 }
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     _asyncHandle.Abort();
 }
Example #11
0
 public void Abort()
 {
     handle.Abort();
 }
Example #12
0
 private void HandleFailure(Action <Error> onFailure, RestRequestAsyncHandle handle, Error error)
 {
     handle.Abort();
     CleanUp();
     onFailure(error);
 }