471,610 Members | 1,345 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,610 software developers and data experts.

How do I do a SendMessage like operation in C#

In VC++ When I wanted to send a message to a window from a worker
thread I would use SendMessage. Events only work Semi-well in C#
becuase certain GUI operations require they run in the same thread that
the window exists in. Such as displaying a balloon on the tray. Does
anyone know a good way to do this?

Jan 19 '06 #1
2 1120
In order to make a call to the thread that the UI is running on, you can
call the Invoke method on a control that was created on that thread. This
will allow you to pass a delegate that will get invoked on the UI thread, as
well as the parameters to pass to it.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<ch***************@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
In VC++ When I wanted to send a message to a window from a worker
thread I would use SendMessage. Events only work Semi-well in C#
becuase certain GUI operations require they run in the same thread that
the window exists in. Such as displaying a balloon on the tray. Does
anyone know a good way to do this?

Jan 19 '06 #2
Hi,

I've actually written an article about this a while back. http://www.lowendahl.net/content.asp...pContent=csa31
It shows a pattern you can use to ensure that your events execute on the
correct thread.

--
Patrik L÷wendahl [C# MVP]
http://www.lowendahl.net

In order to make a call to the thread that the UI is running on,
you can call the Invoke method on a control that was created on that
thread. This will allow you to pass a delegate that will get invoked
on the UI thread, as well as the parameters to pass to it.

Hope this helps.

<ch***************@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
In VC++ When I wanted to send a message to a window from a worker
thread I would use SendMessage. Events only work Semi-well in C#
becuase certain GUI operations require they run in the same thread
that the window exists in. Such as displaying a balloon on the tray.
Does anyone know a good way to do this?

Jan 19 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Mark Overstreet | last post: by
3 posts views Thread by JSK | last post: by
reply views Thread by SamSpade | last post: by
3 posts views Thread by Rob | last post: by
18 posts views Thread by Lars Netzel | last post: by
4 posts views Thread by Abubakar | last post: by
1 post views Thread by Necromis | last post: by
5 posts views Thread by michelqa | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by MichaelMortimer | last post: by
reply views Thread by CCCYYYY | last post: by
1 post views Thread by ZEDKYRIE | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.