In the code sample below , how to get input argument content inside callback method "MethodDone" ?
I don't want to pass the input parameter again as the third argument of BeginInvoke , 'cause I want to call EndInvoke in callback method .
static class Program
{
static void Main()
{
Action<string> del = new Action<string>(SomeMethod);
del.BeginInvoke("input parameter", MethodDone, del);
}
static void MethodDone(IAsyncResult ar)
{
//how to get input parameter here ?
Action<string> del = (Action<string>)ar.AsyncState;
del.EndInvoke(ar);
}
static void SomeMethod(string input)
{
//do something
}
}
You can write like this and use anything:
From MSDN:
Here is the link to the article for further reading: http://msdn.microsoft.com/en-us/library/a06c0dc2(v=vs.110).aspx