|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Callback from a threadHello,
I have a worker thread ( a shared method in a class) that needs to callback to another (monitoring) class on certain events. I have been unable to figure out how to pass the callback address of a delegate in the monitoring class to the thread. Could someone please point me to a sample or give a few clues. I have tried to use TLS but can't figure out how to send the result of the "address of" operator and then recover it by using SetData and GetData. Thanks, Sid. Threads can Raise Events. Just be aware that the event handler in the
monitoring class will be running in the secondary thread so it should only do thread-safe operations. If you need to access UI elements from the secondary thread or in the event handler, you will need to marshal the call back to the UI thread using the Control.Invoke method of the UI element you wish to update. Show quoteHide quote "sidpr***@softtools.com" wrote: > Hello, > > I have a worker thread ( a shared method in a class) that needs to callback > to another (monitoring) class on certain events. I have been unable to > figure out how to pass the callback address of a delegate in the monitoring > class to the thread. Could someone please point me to a sample or give a few > clues. I have tried to use TLS but can't figure out how to send the result > of the "address of" operator and then recover it by using SetData and > GetData. > > Thanks, > Sid. > > > In VS 2005, take a look at the Background worker class.
Mike Ober. Show quoteHide quote "TrtnJohn" <TrtnJ***@discussions.microsoft.com> wrote in message news:E8BFC060-303C-4018-A0E4-5677025628F8@microsoft.com... > Threads can Raise Events. Just be aware that the event handler in the > monitoring class will be running in the secondary thread so it should only do > thread-safe operations. If you need to access UI elements from the secondary > thread or in the event handler, you will need to marshal the call back to the > UI thread using the Control.Invoke method of the UI element you wish to > update. > > "sidpr***@softtools.com" wrote: > > > Hello, > > > > I have a worker thread ( a shared method in a class) that needs to callback > > to another (monitoring) class on certain events. I have been unable to > > figure out how to pass the callback address of a delegate in the monitoring > > class to the thread. Could someone please point me to a sample or give a few > > clues. I have tried to use TLS but can't figure out how to send the result > > of the "address of" operator and then recover it by using SetData and > > GetData. > > > > Thanks, > > Sid. > > > > > > > Thanks, however I am working with VS 2003.
sid. Show quoteHide quote "Michael D. Ober" <ober***@.alum.mit.edu.nospam> wrote in message news:NvaLf.59$6I.32@newsread3.news.pas.earthlink.net... > In VS 2005, take a look at the Background worker class. > > Mike Ober. > > "TrtnJohn" <TrtnJ***@discussions.microsoft.com> wrote in message > news:E8BFC060-303C-4018-A0E4-5677025628F8@microsoft.com... >> Threads can Raise Events. Just be aware that the event handler in the >> monitoring class will be running in the secondary thread so it should >> only > do >> thread-safe operations. If you need to access UI elements from the > secondary >> thread or in the event handler, you will need to marshal the call back to > the >> UI thread using the Control.Invoke method of the UI element you wish to >> update. >> >> "sidpr***@softtools.com" wrote: >> >> > Hello, >> > >> > I have a worker thread ( a shared method in a class) that needs to > callback >> > to another (monitoring) class on certain events. I have been unable to >> > figure out how to pass the callback address of a delegate in the > monitoring >> > class to the thread. Could someone please point me to a sample or give >> > a > few >> > clues. I have tried to use TLS but can't figure out how to send the > result >> > of the "address of" operator and then recover it by using SetData and >> > GetData. >> > >> > Thanks, >> > Sid. >> > >> > >> > >> > > > The thread is a shared method and to resolve this issue I have added a
shared variable that holds the callback address. In the design of my application this works just fine since there is only a single thread instance running at once. Thanks to those who replied, Sid. Show quoteHide quote "TrtnJohn" <TrtnJ***@discussions.microsoft.com> wrote in message news:E8BFC060-303C-4018-A0E4-5677025628F8@microsoft.com... > Threads can Raise Events. Just be aware that the event handler in the > monitoring class will be running in the secondary thread so it should only > do > thread-safe operations. If you need to access UI elements from the > secondary > thread or in the event handler, you will need to marshal the call back to > the > UI thread using the Control.Invoke method of the UI element you wish to > update. > > "sidpr***@softtools.com" wrote: > >> Hello, >> >> I have a worker thread ( a shared method in a class) that needs to >> callback >> to another (monitoring) class on certain events. I have been unable to >> figure out how to pass the callback address of a delegate in the >> monitoring >> class to the thread. Could someone please point me to a sample or give a >> few >> clues. I have tried to use TLS but can't figure out how to send the >> result >> of the "address of" operator and then recover it by using SetData and >> GetData. >> >> Thanks, >> Sid. >> >> >>
trying to understand classes
initialize a complex constant in a class SendKeys Doesn't Always Work? SQL question in VB.net and Access MDI Child Forms Form StartUpPosition RaiseEvent not working correctly Text from a Word.Doc Putting an application into my vb.net control (like a panel) Sending/Receiving SOAP Message using VB.NET |
|||||||||||||||||||||||