Starting an Application Message Loop

G

Guest

I need to know how to start an application message loop using .NET Compact
Framework and without displaying a window.

BACKGROUND INFO: I have a standalone application running under Windows CE
5.0, coded in C# and using .NET Compact Framework 2.0. It creates a single
dialog window, but should not display that window until a hardware event
occurs. On way to implement this is to create the dialog, then wait on an
AutoResetEvent until the hardware event occurs, then call ShowDialog() when
the event is set. This works fine.

However, my lead wants me to design the program so that it can receive
WM_CLOSE messages and shut itself down, even while the dialog window is NOT
being displayed. (These messages will come from another software component
in the system.) I assume this means that I need to have a message loop
running in my program while I am waiting for the hardware event to be set.
If my program is just waiting on an AutoResetEvent, I will not have a way to
receive messages.

The standard way to initiate a message loop for window messages is to call
Application.Run(), and I could do this after creating a separate thread to
wait for the AutoResetEvent. However, calling Application.Run() causes the
dialog window to be displayed. Even if I set the visibility of the dialog
window to false immediately, it still flashes on the screen momentarily.
This doesn't look good.

QUESTIONS: Is there some way to start an application message loop without
calling Application.Run()? Is there some way to prevent my dialog window
from being displayed when Application.Run() is called?

- Carl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top