how can i execute a delegate on the thread that created the object ? (object that is not control )

  • Thread starter Thread starter Gaurav Vaish
  • Start date Start date
how can i execute a delegate on the thread that created the object ?
(the object is not control, but im looking somthing like the control.invoke
, but to my object)
 
roni said:
how can i execute a delegate on the thread that created the object ?
(the object is not control, but im looking somthing like the
control.invoke , but to my object)

I think that's not possible. Control.Invoke() sends a window message to the
control, the message gets picked up in the control's message loop and gets
handled from there. If you have a simple object but no Control or Form, you
have no message loop and thus can't do that.

If you only want to signal another thread that it should start doing
something, you can use the Manual- or AutoResetEvent or Monitor classes.

hth,
Max
 
roni said:
how can i execute a delegate on the thread that created the object ?
(the object is not control, but im looking somthing like the control.invoke
, but to my object)

Well, what's the other thread doing? It will have to be waiting for you
(or someone else) to ask it to handle your request. You can't just
hijack a thread and tell it to do something if it's in the middle of
doing something else.

Objects don't automatically know which thread they've been created on,
either.
 
Back
Top