Notifying users of long-run processes

There’s a thread in the newsgroups where someone is trying to show a Notification before his app does some long-running process. Here’s an example of how it’s done.

  1. Create a WM 5.0 Windows app, then add a reference to ‘Microsoft.WindowsCE.Forms’.

  2. Add a single Button to the Form and name it ‘workButton’

  3. Add this to the top of the code page:

    using System.Threading;
    using Microsoft.WindowsCE.Forms;

  4. Replace the entire non-designer Form class code with this:

    public partial class Form1 : Form
      public Form1()
        workButton.Click += new System.EventHandler(workButton_Click);

      delegate void EventDelegate();

      Notification m_workNotify = new Notification();
      Control m_invoker = new Control();
      EventDelegate m_workCompleteDelegate;

      private void workButton_Click(object sender, EventArgs e)
        // disable the button so it can’t be clicked again until work is done
        workButton.Enabled = false;
        m_workCompleteDelegate = new EventDelegate(OnWorkComplete);

        Thread workThread = new Thread(new ThreadStart(WorkProc));
        m_workNotify.Text = “I’m doing important stuff”;
        m_workNotify.Caption = “Please wait…”;
        m_workNotify.InitialDuration = 5;

        m_workNotify.Visible = true;


      void OnWorkComplete()
        // re-enable the button
        workButton.Enabled = true;

      void WorkProc()
        // simulate working

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s