Example #1
0
 private void ExamTimeOut()
 {
     if (_examTimeout != 0)
     {
         Thread.Sleep(_examTimeout * 1000);
     }
     if (_examTOThread.ThreadState == ThreadState.Running)
     {
         TimeOutEvent handler = ExamTimeOutEvent;
         handler(this, new TimeOutEventArgs(_examTimeout));
     }
 }
Example #2
0
        public SplashView(IConfigurationService configurationService)
        {
            InitializeComponent();

            pictureBox2.Parent = this.pictureBox1;
            pictureBox2.BringToFront();

            label1.Parent = this.pictureBox1;
            label1.BringToFront();

            loadingLabel.Parent = this.pictureBox1;
            loadingLabel.BringToFront();

            loadingWorker.DoWork += (object sender, DoWorkEventArgs e) =>
            {
                loadingWorker.ReportProgress(1, new LoadingWorkerStage("Loading Configuration"));

                var config = configurationService.GetAsync().Result;

                ApplicationStore.RefreshStore(config).Wait();
            };

            loadingWorker.ProgressChanged += (sender, e) =>
            {
                loadingLabel.Text = ((LoadingWorkerStage)e.UserState) !.Phase;
            };
            loadingWorker.RunWorkerCompleted += (sender, e) =>
            {
                loadingLabel.Text = @"Starting App";

                splashTimer.Enabled = true;
                splashTimer.Start();
            };

            splashTimer.Tick += (sender, e) =>
            {
                splashTimer.Enabled = false;
                splashTimer.Stop();

                TimeOutEvent?.Invoke();
                Close();
            };

            loadingWorker.RunWorkerAsync();
        }
Example #3
0
 private void StateTimeOut()
 {
     try
     {
         if (_stateTimeout != 0)
         {
             Thread.Sleep(_stateTimeout * 1000);
         }
         if (Thread.CurrentThread.ThreadState == ThreadState.Running)
         {
             TimeOutEvent handler = StateTimeOutEvent;
             handler(this, new TimeOutEventArgs(_stateTimeout));
         }
     }
     catch (ThreadAbortException e)
     {
         Thread.ResetAbort();
     }
 }
Example #4
0
 private void ScanCallBackMethod(IAsyncResult ar)
 {
     try
     {
         ScannerSocket = ar.AsyncState as Socket;
         if (ScannerSocket != null)
         {
             ScannerSocket.EndConnect(ar);
             Connected = true;
         }
     }
     catch (Exception ex)
     {
         Connected = false;
     }
     finally
     {
         TimeOutEvent.Set();//解除被阻塞的连接线程
     }
 }
Example #5
0
 private void LwmCallBack(IAsyncResult ar)
 {
     try
     {
         LwmSocket = ar.AsyncState as Socket;
         if (LwmSocket != null)
         {
             LwmSocket.EndConnect(ar);
             Connected = true;
         }
     }
     catch (Exception)
     {
         Connected = false;
     }
     finally
     {
         TimeOutEvent.Set();//解除阻塞线程
     }
 }