.NET variable problem / asynchronous call-back

jhunt24

New member
Joined
May 19, 2008
Messages
1
Programming Experience
1-3
Hi,

I'm calling a data-server via a third party dll in .NET to retrieve custom data. The call to the dll fires out ok, and the implemented call-back functions are called (asynchronously) ok. The problem is that when the data set appears in the call-back function (as a varient array) it cannot be "seen" by the code that initiated the server call i.e. even with a Public Shared variable the value is lost.
I've done a bit of research on threading and delegates, but even my delegate variable cannot be seen by the main thread.
I suppose my question is, am I barking up the wrong tree with delegates and threading to solve this??
 
All data can be "seen" by all threads, so you must be misunderstanding something. If your callback method is executed on a background thread and you want to update the UI then you need to marshal a method call to the UI thread.

http://www.vbforums.com/showthread.php?t=498387
 
Hi,

I'm calling a data-server via a third party dll in .NET to retrieve custom data. The call to the dll fires out ok, and the implemented call-back functions are called (asynchronously) ok. The problem is that when the data set appears in the call-back function (as a varient array) it cannot be "seen" by the code that initiated the server call

Huh? It's not supposed to be.

Suppose Thread 1 starts the call then goes off to do other things. When the call completes async, the framework makes another thread (e.g. Thread 2) and calls the relevant delegated method, passing in as a method parameter, the data returned from the async call.
Thread 2 should not attempt to retrieve any shared instance of anything and get data out of it; Thread2 was given all the data it was ever intended to have via a parameter of the async method.

Most the microsoft stuff I looked at to show you an example of async uses IAsyncResult, which works slightly differently to what you seem to be describing. If you have some code to show us, please do
 
Back
Top