Example #1
0
        public static void RunTimer(int timeOutInSec)
        {
            StateObjClass StateObj = new StateObjClass();
            StateObj.MaxValue = (int) timeOutInSec / 1;
            StateObj.TimerCanceled = false;
            StateObj.SomeValue = 1;
            System.Threading.TimerCallback TimerDelegate =
                new System.Threading.TimerCallback(TimerTask);

            // Create a timer that calls a procedure every 2 seconds. 
            // Note: There is no Start method; the timer starts running as soon as  
            // the instance is created.
            System.Threading.Timer TimerItem =
                new System.Threading.Timer(TimerDelegate, StateObj, 1000, 1000);

            // Save a reference for Dispose.
            StateObj.TimerReference = TimerItem;
        }
Example #2
0
        void Selected_Serial(object sender, EventArgs e, string selected_port)
        {
            Console.WriteLine("Selected port");
            Console.WriteLine(selected_port);
            Console.ReadLine();
            SelectedSerialPort = new SerialPort(selected_port);
            if ( ! SelectedSerialPort.IsOpen)
            {
                SelectedSerialPort.Open();

            };
            StateObjClass StateObj = new StateObjClass();
            StateObj.TimerCanceled = false;
            System.Threading.TimerCallback TimerDelegate = new System.Threading.TimerCallback(dataCheck);
            System.Threading.Timer TimerItem = new System.Threading.Timer(TimerDelegate, StateObj, 1000, 3000);
            StateObj.TimerReference = TimerItem;
            // SelectedSerialPort.WriteLine("Send Data \n");
        }
Example #3
0
        //protected override void SetVisibleCore(bool value)
        //{
        //    if (!_showWindow)
        //    {
        //        base.SetVisibleCore(false);
        //        return;
        //    }
        //    base.SetVisibleCore(value);
        //}
        private void StartReadySignal()
        {
            textBox1.Text += string.Format("Starting to send EX_READY message...{0}", Environment.NewLine);

            _stateObj = new StateObjClass();
            _stateObj.TimerCanceled = false;
            System.Threading.TimerCallback TimerDelegate =
                new System.Threading.TimerCallback(SendReadySignal);

            // Create a timer that calls a procedure every 2 seconds.
            // Note: There is no Start method; the timer starts running as soon as
            // the instance is created.
            System.Threading.Timer TimerItem =
                new System.Threading.Timer(TimerDelegate, _stateObj, 100, 1000);

            // Save a reference for Dispose.
            _stateObj.TimerReference = TimerItem;

            textBox1.Text += string.Format("Waiting for EX_OK message...{0}", Environment.NewLine);
        }