WndProc + Event = Error?

  • Thread starter Thread starter Trollpower
  • Start date Start date
T

Trollpower

Dear NG,

ive encountered the following issue. Ive made a inherited class from
MessageWindow overriding the WndProc method. I fire a self defined
event if a certain message occurs. In my Form I catch the event and
have the GUI make some changes. All the functions work ok except the
fact that the GUI-changes take no effect. Additionally I cant use the
GUI anymore after the event fires (eg. Buttons and selfmade controls
dont work anymore).

Does anyone knows what the problem is? The code for the overwritten
WindowMessage follows:

public class WindowsMessage : Microsoft.WindowsCE.Forms.MessageWindow
{
private const int WM_NEW_MESSAGE = 0xABCE;

public WindowsMessage()
{
}

protected override void WndProc(ref Microsoft.WindowsCE.Forms.Message
msg)
{
if (msg.Msg == WM_NEW_MESSAGE)
{
neueNachricht(this, null);
}

base.WndProc(ref msg);
}

public event System.EventHandler neueNachricht;
}

Any help or hint is appreciated, thanks in advance

Jens
 
Try using ThreadPool.QueueUserWorkItem to call a function that triggers
the desired event when the next available thread can handle it. Then
you don't have to worry about an event blocking WndProc.

I'm not sure, but I think since your triggering an event you don't need
to control.invoke even though your using the threadpool.

- Russ
 
Back
Top