I am having trouble understanding how asynccallbacks work. I have a method in a separate class (call this class "Foo") that requires me to pass in an asynccallback method and an object.
This method is supposed to download some content as a string.
public void sampleFunction(AsyncCallback callback, object x)
{
//download some content as a string
}
Then I have my asynccallback method and my method from where I call the above method:
public static void test(IAsyncResult result)
{
Console.WriteLine("Reached");
//Is result the string that should have been downloaded? Confused
Console.WriteLine(result);
}
public static void sampleFunction2()
{
Foo z;
object t = "hello";
AsyncCallback callback = new AsyncCallback(test);
z.sampleFunction(callback, t);
}
After calling sampleFunction2, nothing prints to the console. What am I doing/understanding wrong?