示例#1
0
            public object DoWork(MB.Util.AsynWorkThread workThread, DoWorkEventArgs e)
            {
                // The asynchronous method puts the thread id here.

                int threadId;

                // Create an instance of the test class.
                AsyncDemo ad = new AsyncDemo();

                // Create the delegate.
                AsyncMethodCaller caller = new AsyncMethodCaller(ad.TestMethod);

                // Initiate the asychronous call.
                IAsyncResult result = caller.BeginInvoke(3000,
                                                         out threadId, null, null);

                Thread.Sleep(0);
                workThread.ReportProgress(0, string.Format("Main thread {0} does some work.",
                                                           Thread.CurrentThread.ManagedThreadId));

                // Call EndInvoke to wait for the asynchronous call to complete,
                // and to retrieve the results.
                string returnValue = caller.EndInvoke(out threadId, result);

                workThread.ReportProgress(1, string.Format("The call executed on thread {0}, with return value \"{1}\".",
                                                           threadId, returnValue));

                e.Result = returnValue;
                return(returnValue);
            }
示例#2
0
 public void Dispose()
 {
     try {
         _DownloadWaitDialog.Dispose();
         _DownloadWaitDialog = null;
         _WorkThread.Dispose();
         _WorkThread = null;
     }
     catch { }
 }
示例#3
0
        public object DoWork(MB.Util.AsynWorkThread workThread, DoWorkEventArgs e)
        {
            int sum = 0;

            for (int i = 0; i < 100; i++)
            {
                sum += i;

                workThread.ReportProgress(0, string.Format("Main thread {0} does some work.",
                                                           Thread.CurrentThread.ManagedThreadId));
                Thread.Sleep(200);
            }
            return(sum);
        }
        /// <summary>
        /// 在后台线程中异步调用 获取数据的方法。
        /// </summary>
        /// <param name="asynCaller"></param>
        /// <param name="showWaitDialog"></param>
        public BackWorkWithWaitDialog(AsyncMethodCallerDelegate asynCaller)
        {
            _AsynCaller = asynCaller;

            _WorkThread = new MB.Util.AsynWorkThread();


            _WaitDialog = new WaitDialogForm(this);

            // _WaitDialog.ClickCanceled += new EventHandler(_WaitDialog_ClickCanceled);
            _WaitProcessState = new MB.WinBase.Common.WorkWaitDialogArgs();

            iniAsynWorkThread();
        }
        /// <summary>
        ///  在后台线程中异步调用 获取数据的方法。
        /// </summary>
        public AsynLoadDataHelper(MB.WinBase.IFace.IAsynClientQueryRule asynRule, bool isTotalPageDisplayed, bool isQueryAll)
        {
            _IsTotalPageDisplayed = isTotalPageDisplayed;
            _IsQueryAll           = isQueryAll;
            _DataList             = new SortedList <int, byte[]>();

            _WorkThread    = new MB.Util.AsynWorkThread();
            _AsynQueryRule = asynRule;

            _AsynQueryRule.GetBufferByIndexCompleted += new EventHandler <MB.WinBase.Common.GetBufferByIndexCompletedEventArgs>(_AsynQueryRule_GetBufferByIndexCompleted);

            _WaitDialog = new WaitDialogForm(this);
            _WaitDialog.ClickCanceled += new EventHandler(_WaitDialog_ClickCanceled);

            _WaitProcessState = new MB.WinBase.Common.WorkWaitDialogArgs();

            iniAsynWorkThread();
        }
示例#6
0
        /// <summary>
        /// 判断并显示下载处理窗口。
        /// </summary>
        /// <returns></returns>
        public bool DownloadVersionFileDialog()
        {
            bool b = CheckExistsNewVersion(out _CurrentNewVersionNumber);

            if (!b)
            {
                return(false);
            }
            //初始化下栽文件
            iniForDownloadFiles(_CurrentNewVersionNumber);

            _WorkThread         = new MB.Util.AsynWorkThread();
            _DownloadWaitDialog = new FileDownloadWaitDialog(this, _AutoUpdate, _VersionDownloadFiles);
            _DownloadWaitDialog.ClickCanceled += new EventHandler(_DownloadWaitDialog_ClickCanceled);
            DialogResult re = _DownloadWaitDialog.ShowDialog();

            return(!_WaitProcessState.Cancel);
        }