none
Non-graphical application showing a dialog box

    Question

  • I've created a C# Pocket PC non-graphical application designed to run in the background forever.  Let's call it ShowReminder.

    Occasionally it needs to display some information to the user in a dialog box.

    To make the forms functionality available, I have simply added a using to my code:


    using System.Windows.Forms;
     


    The application runs fine - exactly how you would expect it to.  The user presses OK to dismiss the dialog and the application carries on running in the background.

    However, I encounter a problem when running a second C# CE application on the same device at the same time, this time a Windows application.  Let's call this second application 'FunkyApp'.  FunkyApp is shown to be running by a process viewer, but it is unable to display its main window.

    If I kill ShowReminder using a process viewer, FunkyApp immediately starts up and shows its main window without any further user intervention.

    Here's the thing, FunkyApp is incapable of starting up only AFTER ShowReminder has had its dialog dismissed for the first time.  Up until that time, FunkyApp starts up and runs correctly.

    Here is ShowReminder's function which shows its dialog:


    private bool ShowReminder()
    {
     const string funcName = "ShowReminder(): ";
     frmReminder reminderDlg;
     int dialogResult;

     try
     {
      reminderDlg = new frmReminder();
      reminderDlg.ShowDialog();
      dialogResult = reminderDlg.GetDialogResult();
      ...


     


       
    I'd rather not create ShowReminder as a new Windows application and fiddle about with making its main window invisible, thereby simulating a non-graphical application.

    Can anyone please help?  Thanks.

    Monday, October 03, 2005 1:54 PM

Answers

  • Just in case anyone was following this (doubtful!), I found a workaround:

    After the dialog is shown, I have a main loop which calls Application.DoEvents every second.  It seems that if I don't call this, the framework cannot process other application's window events.

    Now you'd think Application.Exit would be what I need to shut down the message pumps for my application, but it just doesn't work in the slightest.

    I think there are various other workarounds I could have employed.  Making the form invisible after the user has dismissed it or starting a dedicated thread to handle the displaying of the form.
    Tuesday, October 04, 2005 7:47 AM

All replies

  • A bit more info on the subject:

    Before the dialog is shown, ShowReminder is shown to have three threads running.  After the dialog is shown, it has four.  It still has four when the dialog is dismissed.  Maybe this fourth (windows messaging?) thread is locking up the framework somehow.
    Monday, October 03, 2005 2:08 PM
  • Just in case anyone was following this (doubtful!), I found a workaround:

    After the dialog is shown, I have a main loop which calls Application.DoEvents every second.  It seems that if I don't call this, the framework cannot process other application's window events.

    Now you'd think Application.Exit would be what I need to shut down the message pumps for my application, but it just doesn't work in the slightest.

    I think there are various other workarounds I could have employed.  Making the form invisible after the user has dismissed it or starting a dedicated thread to handle the displaying of the form.
    Tuesday, October 04, 2005 7:47 AM