コード例 #1
0
        public void Start()
        {
            if (StartFun == null || StopFun == null)
            {
                return;
            }
            var thread = new Thread(delegate()
            {
                using (var a = new ControlActionable(this.buttonControlService, c => c.Enabled = false, c => c.Enabled = true))
                {
                    Func <Status> action = null;
                    switch (Status)
                    {
                    case Status.Start:
                        action = StopFun;
                        break;

                    case Status.Stop:
                        action = StartFun;
                        break;
                    }
                    this.Status = action();
                }
            });

            thread.Start();
        }
コード例 #2
0
 private void TestContection()
 {
     smartThreadPool.QueueWorkItem(() => {
         using (var a = new ControlActionable(this.buttonTestConnection, c => c.Enabled = false, c => c.Enabled = true))
         {
             try
             {
                 bool ok = ServicesProvider.TestServiceConnection(this.textBoxHost.Text);
                 if (ok)
                 {
                     pictureBox1.Image = StartImage;
                 }
                 else
                 {
                     pictureBox1.Image = StopImage;
                 }
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
                 LoggerHelper.Instance.Error(ex);
                 pictureBox1.Image = StopImage;
             }
         }
     });
 }
コード例 #3
0
        private void wsnButtonStart_Click(object sender, EventArgs e)
        {
            if (StartFun == null || StopFun == null)
            {
                return;
            }
            var thread = new Thread(delegate()
            {
                using (var a = new ControlActionable(this.buttonControlService, c => c.Enabled = false, c => c.Enabled = true))
                {
                    Func <Status> action = null;
                    switch (Status)
                    {
                    case Status.Start:
                        action = StopFun;
                        break;

                    case Status.Stop:
                        action = StartFun;
                        break;
                    }
                    this.Status = action();
                }
            });

            thread.Start();
        }