Asynchronous call and Asyncstate
Hi!
How to work with the Asyncstate in the target method?
That is, I call a BeginInvoke with a state object ...
MyDelegateObject DO = new MyDelegateObject(MyTargetMethod);
DO.BeginInvoke(MyCallBack,MyStateObject);
Target method works...
MyTargetMethod()
{
// Where is MyStateObject?
// Code to complete work ...
}
And AsyncCallback is called when target method finish...
MyCallBack(IAsyncResult ar)
{
// ar.AsyncState <-- here is my StateObject, but is the equal that when i call BeginInvoke ...
}
But... I want for example, that the result of the target method modify the state object and thus have a result, or when i call to EndInvoke IAsyncResult.Asyncstate have the results of the target method...
I see that i can use outers variables but... then what's the utility of AsyncState? :P
Regards.

