473,398 Members | 2,120 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Callback from a thread

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.
Feb 22 '06 #1
4 1382
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.

"si******@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.

Feb 22 '06 #2
In VS 2005, take a look at the Background worker class.

Mike Ober.

"TrtnJohn" <Tr******@discussions.microsoft.com> wrote in message
news:E8**********************************@microsof t.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.

"si******@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.


Feb 23 '06 #3
Thanks, however I am working with VS 2003.

sid.

"Michael D. Ober" <obermd.@.alum.mit.edu.nospam> wrote in message
news:Nv************@newsread3.news.pas.earthlink.n et...
In VS 2005, take a look at the Background worker class.

Mike Ober.

"TrtnJohn" <Tr******@discussions.microsoft.com> wrote in message
news:E8**********************************@microsof t.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.

"si******@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.
>
>
>


Feb 23 '06 #4
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.
"TrtnJohn" <Tr******@discussions.microsoft.com> wrote in message
news:E8**********************************@microsof t.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.

"si******@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.

Feb 23 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: scott ocamb | last post by:
hello I have implemented a solution using async methods. There is one async method that can be invoked multiple times, ie there are multiple async "threads" running at a time. When these...
5
by: Francois De Serres | last post by:
Hiho, could somebody please enlighten me about the mechanics of C callbacks to Python? My domain is more specifically callbacks from the win32 API, but I'm not sure that's where the problem...
1
by: johnny | last post by:
In a multi-threaded application, say a worker thread makes an asynchronous call and specifies a callback method. But before the callback is executed, the thread is aborted by its creator. What is...
1
by: Barry Anderberg | last post by:
I am using asynch sockets and so I call BeginReceive and then in my callback function I have certain events that would cause me to want to throw an exception. The problem of course is that the...
1
by: Dennis Burns | last post by:
I've posted this question before, and since then I've tried a variety of work-arounds, with no success. So, here goes again... I'd like to create forms and open them from within a callback...
4
by: Jim Hammond | last post by:
It would be udeful to be able to get the current on-screen values from a FormView that is databound to an ObjectDataSource by using a callback instead of a postback. For example: public void...
5
by: greg.merideth | last post by:
I have a class that I've provided an event for to be called when the processing in the class is complete (a callback). The class spins up a series of threads for the background operation and I'm...
4
by: Edwin Gomez | last post by:
I'm a C# developer and I'm new to Python. I would like to know if the concept of Asynchronous call-backs exists in Python. Basically what I mean is that I dispatch a thread and when the thread...
6
by: =?Utf-8?B?TWlrZVo=?= | last post by:
I have a thread that parser video-frame from network streaming. It can get up to 1000 frame/second. I want another thread to process video-frame. I can use RaiseEvent or Callback Function. My...
3
by: waldek | last post by:
Hi, I'm trying to handle data passed to Py Callback which is called from C dll. Callback passes data to another thread using Queue module and there the data are printed out. If data is...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.