예제 #1
0
        private void StartCreateThread()
        {
            DateTime startTime        = Convert.ToDateTime(dpStartTime.Text);
            DateTime endTime          = Convert.ToDateTime(dpEndTime.Text);
            int      stationCodeStart = Convert.ToInt32(txtStationStart.Text);
            int      stationCodeEnd   = Convert.ToInt32(txtStationEnd.Text);
            int      oneNum           = Convert.ToInt32(txtNum.Text);
            int      oneSleep         = Convert.ToInt32(txtSleep.Text);
            bool     isStation        = rb1.IsChecked == true;

            FileCopy.IsCopy = (bool)cbFileCopy.IsChecked;
            ThreadHepler threadHelper = new ThreadHepler(this);
            Stopwatch    stopwatch    = new Stopwatch();

            stopwatch.Start();

            threadHelper.Success += new ThreadHepler.SuccessEventHandler((oneself) =>
            {
            });

            threadHelper.Finally += new ThreadHepler.FinallyEventHandler((oneself) =>
            {
                stopwatch.Stop();
                loadingWindow.Close();
                int result = Convert.ToInt32(oneself.Result);
                PrintResultMsg(result, stopwatch.Elapsed);
            });

            threadHelper.BeginInvoke(new ThreadHepler.RequestAction((myObj) =>
            {
                int result = isStation ? CreateDataByDs(startTime, endTime, stationCodeStart, stationCodeEnd, oneNum, oneSleep) :
                             CreateDataByMc(startTime, endTime, stationCodeStart, stationCodeEnd, oneNum, oneSleep);
                return(result);
            }));;
        }
예제 #2
0
파일: ThreadHepler.cs 프로젝트: metoer/myEF
        public virtual void OnError(ThreadHepler oneself)
        {
            if (Error == null)
            {
                return;
            }

            DoMain(new Action(() =>
            {
                Error(oneself);

                //if (IsShowMessage && oneself.Exception != null)
                //{
                //    System.Windows.Forms.MessageBox.Show(oneself.Exception.ToString());
                //}
            }));
        }
예제 #3
0
파일: ThreadHepler.cs 프로젝트: metoer/myEF
        public virtual void OnSuccess(ThreadHepler oneself)
        {
            if (Success == null)
            {
                return;
            }

            DoMain(new Action(() =>
            {
                try
                {
                    Success(oneself);
                }
                catch (Exception ex)
                {
                    this.Exception = ex;
                    OnError(this);
                }
            }));
        }
예제 #4
0
파일: ThreadHepler.cs 프로젝트: metoer/myEF
        public virtual void OnFinally(ThreadHepler oneself)
        {
            if (Finally == null)
            {
                return;
            }

            DoMain(new Action(() =>
            {
                try
                {
                    Finally(oneself);
                }
                catch (Exception ex)
                {
                    this.Exception = ex;
                    OnError(this);
                }
            }));
        }