How can i emulate in .net that function:
BOOL PostMessage( HWND hWnd,
UINT Msg,
WPARAM wParam,
LPARAM lParam
);I need a simple async event firing for my WindowsForm without any
callbacks. What is the simplest way for that?thanks in advSerg.

Re: the simplest way for async events? by Serg

Serg
Fri Jun 11 04:32:08 CDT 2004

found myself
I think it as simple as possible:

MyDelegate d = new MyDelegate (w.method);
d.BeginInvoke (null, null);



"Serg" <serg_N0__SPAM_@alef.ru> ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ × ÎÏ×ÏÓÔÑÈ ÓÌÅÄÕÀÝÅÅ:
news:eUxppA5TEHA.3300@TK2MSFTNGP09.phx.gbl...
> How can i emulate in .net that function:
> BOOL PostMessage( HWND hWnd,
> UINT Msg,
> WPARAM wParam,
> LPARAM lParam
> );I need a simple async event firing for my WindowsForm without any
> callbacks. What is the simplest way for that?thanks in advSerg.
>
>



Re: the simplest way for async events? by jchREMOVE

jchREMOVE
Fri Jun 11 04:54:01 CDT 2004

Hey Serg,

Using BeginInvoke on a delegate is certainly a way of doing this. But it is not quite the same as the good ol' PostMessage since BeginInvoke will use a thread from the thread pool. If you access your form or other windows controls in the method for the delegate, make sure that you use Control.Invoke so that the controls are only accessed by their owner thread.

Regards, Jakob.

"Serg" wrote:

> found myself
> I think it as simple as possible:
>
> MyDelegate d = new MyDelegate (w.method);
> d.BeginInvoke (null, null);
>
>
>
> "Serg" <serg_N0__SPAM_@alef.ru> Ã?Ã?Ã?Ã?Ã?Ã?Ã?/Ã?Ã?Ã?Ã?Ã?Ã?Ã?Ã? Ã? Ã?Ã?Ã?Ã?Ã?Ã?Ã?Ã? Ã?Ã?Ã?Ã?Ã?Ã?Ã?Ã?Ã?:
> news:eUxppA5TEHA.3300@TK2MSFTNGP09.phx.gbl...
> > How can i emulate in .net that function:
> > BOOL PostMessage( HWND hWnd,
> > UINT Msg,
> > WPARAM wParam,
> > LPARAM lParam
> > );I need a simple async event firing for my WindowsForm without any
> > callbacks. What is the simplest way for that?thanks in advSerg.
> >
> >
>
>
>

Re: the simplest way for async events? by Jon

Jon
Fri Jun 11 04:56:14 CDT 2004

Serg <serg_N0__SPAM_@alef.ru> wrote:
> found myself
> I think it as simple as possible:
>
> MyDelegate d = new MyDelegate (w.method);
> d.BeginInvoke (null, null);

That will invoke your delegate on a threadpool thread, not on the UI
thread. If you need it to be on the UI thread, use
Control.BeginInvoke(d, ...) instead.

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Re: the simplest way for async events? by Serg

Serg
Fri Jun 11 07:28:26 CDT 2004

Thank you Jon.
This is exactly what i need.


"Jon Skeet [C# MVP]" <skeet@pobox.com> ???????/???????? ? ????????
?????????: news:MPG.1b33921b7e477fb698abfb@msnews.microsoft.com...
> Serg <serg_N0__SPAM_@alef.ru> wrote:
> > found myself
> > I think it as simple as possible:
> >
> > MyDelegate d = new MyDelegate (w.method);
> > d.BeginInvoke (null, null);
>
> That will invoke your delegate on a threadpool thread, not on the UI
> thread. If you need it to be on the UI thread, use
> Control.BeginInvoke(d, ...) instead.
>
> --
> Jon Skeet - <skeet@pobox.com>
> http://www.pobox.com/~skeet
> If replying to the group, please do not mail me too