Ejemplo n.º 1
0
 public void Abort()
 {
     if (asyncHandle != null)
     {
         asyncHandle.Abort();
     }
 }
Ejemplo n.º 2
0
 public void Abort()
 {
     try
     {
         _handle.Abort();
     }
     catch (Exception) { }
 }
Ejemplo n.º 3
0
 public void Stop()
 {
     m_Running = false;
     ClearTexture();
     if (m_Handle != null)
     {
         m_Handle.Abort();
     }
 }
Ejemplo n.º 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.");
         }
     }
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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;
                    }
                });
            });
        }
Ejemplo n.º 9
0
 public void OnNavigatedFrom(NavigationContext navigationContext)
 {
     _serverUpdateActionHandle?.Abort();
 }
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     _asyncHandle.Abort();
 }
Ejemplo n.º 11
0
 public void Abort()
 {
     handle.Abort();
 }
Ejemplo n.º 12
0
 private void HandleFailure(Action <Error> onFailure, RestRequestAsyncHandle handle, Error error)
 {
     handle.Abort();
     CleanUp();
     onFailure(error);
 }