Question : Timer doesn't seem to be

The following code activates a scale by setting a value high for .3 seconds then setting it low for .1 second. The scale starts if  the process is stopped at the line  that reads "  waitForTimer(.3);" then contiued after a few seconds. If the code runs as designed the scale doesn't start.

It appears the waitForTimer method is not producing what I am seeking. I need it to delay for a specified amount of time.

Thanks

 private void StartScale_Click(object sender, EventArgs e)
        {  
         ushort DataValue = 128;
            ULStat = DaqBoard.DOut(portNum, DataValue);
            waitForTimer(.3);

            DataValue = 0;
            ULStat = DaqBoard.DOut(portNum, DataValue);
            waitForTimer(.1);

            getBoardData();

}

private void waitForTimer(double TimeToWait)
        {
            timer1.Interval = 1000 ; //Interval is not correct but works for this test
            timer1.Enabled = true;
            timer1.Start();
            timer1.Tick += new EventHandler(timer1_Tick);
        }


        private void timer1_Tick(object sender, EventArgs e)
        {}

Answer : Timer doesn't seem to be

You could do something like:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
        private void StartScale_Click(object sender, EventArgs e)
        {
            StartScale.Enabled = false;

            ushort DataValue = 128;
            ULStat = DaqBoard.DOut(portNum, DataValue);
            waitForTimer(300);

            DataValue = 0;
            ULStat = DaqBoard.DOut(portNum, DataValue);
            waitForTimer(100);

            getBoardData();

            StartScale.Enabled = true;
        }

        private void Delay(int MillisecondsToWait)
        {
            DateTime dt = DateTime.Now.AddMilliseconds(MillisecondsToWait);
            while (dt.Subtract(DateTime.Now).TotalMilliseconds > 0)
            {
                System.Threading.Thread.Sleep(50);
                Application.DoEvents();
            }
        }
Random Solutions  
 
programming4us programming4us