Events

  • Thread starter Thread starter bwahahahaha
  • Start date Start date
B

bwahahahaha

What is the equivelent of PostMessage or SendMessage on WinForms? Is this
possible or the only way to call the event handler directly? What If I cant
call the event handler directly but want to send a message? PInvoke to
PostMessage with control.Handle?
 
Hi bwahahahaha :)
If the called deleagte and the caller are executed in the UI thread owning
the underlaying window's handle the equivalent of SendMessage in
WindowsForms is direct invocation of the delegate (or using Control.Invoke,
which is overkill in this case) and the equivalent of PostMessage is
Control.BeginInvoke. If the caller runs in a thread different than the UI
thread that owns the control's handle the equivalen of SendMessage is
Control.Invoke for PostMessage is again Control.BeginInvoke. In this case
the delegate will be executed by the UI thread.
Be carefull with BeginInvoke guy, though. The delegate invoked via
BeginInvoke will be executed with the highest priority after the caller
method finishes its work. It will be the next executed delegate. They will
be executed even before the windows messages send via SendMessage to the
underlaying native window. It oposites PostMessgae where the message
usually is queued at the end of the message queue and are executed after all
sent messages(of course this is not completely true first because the
windows messages has their own priorities and second because the
GetMessage/PeekMessage can filter the messages).

HTH
B\rgds
100
 

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

Back
Top