Async Methods, Callback (What Thread)

S

scott ocamb

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 threads are complete, the call the Callback method. Each "thread"
calls the same callback method.

What thread does this callback method exist on? My testing indicates the
callback method is not blocked when executed from a given thread when it
completes.

For example thread 1 can execure it's callback , while thread 2 executes
it's callback. No blocking seems to occur.

Any help getting me to understand this would be appreciated.
 
P

Peter Huang [MSFT]

Hi Scott,

I think the CallBack function is reentrant, i.e. each thread that calls the
callback function will have its own function call back stack. Therefore the
this callback method exist on every thread that call the function. If you
want to program multithread application, you may need to synchronize the
data that will be access by the callback function.

Here is a link about Synchronizing Data for Multithreading.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
l/cpconmanagedthreadingsupport.asp


Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top