0

I have a kiosk app written with the .Net Compact Framework that captures barcode scans and sends them to a central server. The process is so fast that my "WAIT" notification never appears. There is no feedback to the user that a successful scan was submitted. I would like to use the Time class to pause the code for 2 seconds so the user is notified. I cannot get it to work properly. I know the Timer class in the Compact Framework lacks some of the methods that the full framework enjoys.

Here is my event assignment

this.timer1.Tick += new EventHandler(StatusTick);

Here is my code to use the timer

interval = Convert.ToInt32(x.ReadAppSetting("display_interval"));
            this.timer1.Interval = interval;

            this.timer1.Enabled = true;

            while (exitFlag == false)
            {
                Application.DoEvents();
            }

            this.timer1.Enabled = false;

Here is my Tick event:

private void StatusTick(object sender, EventArgs e)
    {

        if (interval > 0)
        {
            changeStatusLabel("WAIT");
            labelCardNumber.Text = readerData.Text;
            interval = interval - 1000;
        }
        else
        {
            changeStatusLabel("READY");
            labelCardNumber.Text = "";
            exitFlag = true;

        }
    }

In the Compact Framework there don't seem to be Timer.Start() and Timer.Stop() methods.

Ryan
  • 650
  • 3
  • 15
  • 49
  • I don't know what "sends them to a central server" is but my guess is that it would be better to somehow get notification from that of success or failure. Looping on Application.DoEvents(); is not an ideal solution. – Sam Hobbs Apr 11 '16 at 18:50
  • What exactly is your question? If it's just the absence of `Start()` and `Stop()`, you've already provided the solution yourself (set `timer1.Enabled` to `true` and `false` respectively). – C.Evenhuis Apr 13 '16 at 13:53

1 Answers1

0

You may need to use a delegate to change information on the UI thread. I can't see what you changeStatusLabel() function is doing, but you could try a delegate if you haven't yet.

See: How to update the GUI from another thread in C#?

Community
  • 1
  • 1