Call Application.Run (or even Application.DoEvents) do establish a message
queue for your secondary thread.

A better answer: You should not be performing any long-blocking operations
on your main UI thread.  This rule goes right up there alongside "thread
that creates the window services the window".

(By "it is difficult to free the main thread" I assume you mean your main
UI thread is performing some long-blocking operation -- like socket i/o, or
calculating pi to 3000 decimal places, or what have you.  Don't do that.)

-Shawn
http://www.windojitsu.com/

On Fri, 20 Feb 2004 13:35:57 -0500, Aman Jain <[EMAIL PROTECTED]> wrote:

>Hi Everybody,
>
>The alarm manager in my Windows Forms application has a alarm control
>(User control) that is used to display errors.
>This is created on the Main thread. Whenever any calls are made on this
>control to display errors, we take care to switch to the Main thread
>(windows principle: thread that creates the window services the window)
>using
>
>
>            private void OnAlarmMessageReceived(AlarmMessage msg)
>            {
>                  if(InvokeRequired) // Pass on to GUI thread
>                  {
>                        BeginInvoke(new
>AlarmMsgReceivedHandler(OnAlarmMessageReceived), new Object[] { msg } );
>                        return;
>                  }
>                  // whatever needs to be done
>            }
>
>This works fine but with the requirement that the main thread is free.
>Now, there are many situations where it is difficult to free the main
>thread but there are errors that need to be displayed.
>What I need is a UI thread  that remains alive during the application
>lifetime on which I can create and service the alarm window. In the
>managed world (using C#) , how do we create a thread with a message pump
>as opposed to a worker thread  ?
>
>Any help is greatly appreciated.
>
>Thanks in advance,
>Aman
>
>
>===================================
>This list is hosted by DevelopMentor®  http://www.develop.com
>Some .NET courses you may be interested in:
>
>NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles
>http://www.develop.com/courses/gaspdotnetls
>
>View archives and manage your subscription(s) at http://discuss.develop.com
===================================
This list is hosted by DevelopMentor®  http://www.develop.com
Some .NET courses you may be interested in:

NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles
http://www.develop.com/courses/gaspdotnetls

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to