MessageWindow from separate thread

  • Thread starter Thread starter Tod Johnson
  • Start date Start date
T

Tod Johnson

Hello all,

I've found that it's not impossible to create MessageWindow from
separate thread. Are there any workarounds?

// -- Main thread --
StartDial();

//---- Separate Thread ----
{
while(!end)
{
...
messageWindow = new MyMessageWindow(); <--- messages never
reach WndProc :(

RasDial(IntPtr.Zero, null, params.Buffer, -1,
this.messageHook.Hwnd, ref this.connection);
Thread.Sleep(1000);
}
}
 
Sorry, there was a typo, that's why I'll rephrase the last post:

I've found that can't create MessageWindow from the separate thread.
What is the reason for such behaviour? I have found it on RasDial call
in asynchrous mode when passing MessageWindow as parameter in this code
snippet:
{
while(!end)
{
...
messageWindow = new MyMessageWindow(); <--- messages never
reach WndProc :(

RasDial(IntPtr.Zero, null, params.Buffer, -1,
this.messageHook.Hwnd, ref this.connection);
Thread.Sleep(1000);
}
}

Thank you,
Tod
 
Hell Peter!

thank you for reply. Well, I don't see any reason why it could be wrong.
For every disconnect I will call RasDial with the new messageHook...
 
You probably can't create a MessageWindow from a non-gui thread by the same
token as you can't call directly methods on a control from a different
thread. Why don't you simply create the MessageWindow on your main thread?
 
Back
Top