Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / October 2007

Tip: Looking for answers? Try searching our database.

Sending messages...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Atmapuri - 17 Oct 2007 00:08 GMT
Hi!

I have a thread and would like to send a Windows Message
to the component that encapsulates the thread, so that the
event specified to react on that message would be raised.

I know how to do that in C++, but I am a bit lost with CLR.

Thanks!
Atmapuri
Nicholas Paldino [.NET/C# MVP] - 17 Oct 2007 02:46 GMT
Atmapuri,

   Have you taken a look at the Invoke method on the Control class?  It
will do what you want, you pass it a delegate and arguments to be passed to
the delegate, and it will make the call to the delegate on the thread that
created the control.

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

> Hi!
>
[quoted text clipped - 6 lines]
> Thanks!
> Atmapuri
Atmapuri - 17 Oct 2007 08:32 GMT
Hi!

>    Have you taken a look at the Invoke method on the Control class?  It
> will do what you want, you pass it a delegate and arguments to be passed
> to the delegate, and it will make the call to the delegate on the thread
> that created the control.

The help file says:
"If the control's handle does not exist yet, this method searches up the
control's parent chain
If no appropriate handle can be found, the Invoke method will throw an
exception."

My component does not have a parent. In C++ I would call:

CreateWindowEx(WS_EX_TOOLWINDOW,...

To get the handle.

Thanks!
Atmapuri
Nicholas Paldino [.NET/C# MVP] - 17 Oct 2007 15:56 GMT
Atmapuri,

   Well, if that component is expecting windows messages, then it means
that it is pumping for them on a particular thread.  If you have a thread
id, then you can send a message to that thread queue calliong the
PostThreadMessage API function through P/Invoke.  If you have a handle to a
window that is owned by that thread, then you can call SendMessage through
the P/Invoke layer.

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

> Hi!
>
[quoted text clipped - 17 lines]
> Thanks!
> Atmapuri

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.