Exemple #1
0
 protected void OnCalculatePrimeCompleted(
     CompletedEventArgs e)
 {
     if (Completed != null)
     {
         Completed(this, e);
     }
 }
Exemple #2
0
        // This is the method that the underlying, free-threaded 
        // asynchronous behavior will invoke.  This will happen on
        // an arbitrary thread.
        private void CompletionMethod(
            List<ProxyInfo> proxylistOk,
            Exception exception,
            bool canceled,
            AsyncOperation asyncOp)
        {
            // If the task was not previously canceled,
            // remove the task from the lifetime collection.
            if (!canceled)
            {
                lock (userStateToLifetime.SyncRoot)
                {
                    userStateToLifetime.Remove(asyncOp.UserSuppliedState);
                }
            }

            // Package the results of the operation in a 
            // CalculatePrimeCompletedEventArgs.
            CompletedEventArgs e =
                new CompletedEventArgs(
                proxylistOk,
                exception,
                canceled,
                asyncOp.UserSuppliedState);

            // End the task. The asyncOp object is responsible 
            // for marshaling the call.
            asyncOp.PostOperationCompleted(onCompletedDelegate, e);

            // Note that after the call to OperationCompleted, 
            // asyncOp is no longer usable, and any attempt to use it
            // will cause an exception to be thrown.
        }
Exemple #3
0
        void pv2_ValidateCompleted(object sender, CompletedEventArgs e)
        {
            if (e.Error == null)
            {
                _ThreadNum--;
                ShowMessage("验证列表[" + e.UserState.ToString() + "]", "完成.", "");
                Monitor.Enter(_ProxyListOK);
                _ProxyListOK.AddRange(e.ProxyList);
                Monitor.Exit(_ProxyListOK);

                if (_ThreadNum < 1)
                {
                    ShowMessage("验证列表", "全部完成.", "");
                    ProxyUtility.SaveProxyList_ToConfig(RemoveExitsProxy(_ProxyListOK), _ProxyListFilePath);
                    ShowMessage("验证列表", "保存到配置成功.", "");
                }
            }
            else
            {
                //TODO
                ShowMessage("错误", e.Error.Message, "");
            }
        }