예제 #1
0
            /// <summary>
            /// 清理已经结束的线程
            /// </summary>
            /// <returns></returns>
            private void ColseThread()
            {
                bool Result;

                //获取线程状态
                hState sThread = WaitThreadSignal();

                if (sThread != hState.WAIT_OBJECT_0)
                {
                    Result = false;
                }
                else
                {
                    //获取线程退出码
                    IntPtr ExitCode = GetExitCode();

                    //释放线程资源
                    Result = ResourcesFree(ExitCode);
                }
                try {
                    //运行回调函数
                    if (UserFun == null)
                    {
                        return;
                    }
                    IAsyncResult uResult = UserFun.BeginInvoke(Result, delegate(IAsyncResult ar) {
                        UserFun.EndInvoke(ar);
                    }, null);
                    // 执行50毫秒后超时
                    uResult.AsyncWaitHandle.WaitOne(50, true);
                } catch (Exception) {
                }
            }
예제 #2
0
 private int RuleofN(List <string> lstAttributes, int tmCount, string txnID, Required r, CallBack obj)
 {
     try
     {
         IAsyncResult async = obj.BeginInvoke(lstAttributes, tmCount, txnID, r, null, null);
         int          i     = obj.EndInvoke(async);
         return(i);
     }
     catch (Exception)
     {
         throw;
     }
 }