Hi,
I'm creating an Appdomain to run a piece of code that can literally be any thing. I want my host process to be able when all the word is complete but async calls/threads are blocking my efforts. My code is something like this:
AppDomain ad = AppDomain.CreateDomain(...);
WorkUnit mbro = (WorkUnit)ad.CreateInstanceAndUnwrap(...);
mbro.Run();
And work unit does an async call like this:
class WorkUnit {
public override void Run()
{
WebClient wb = new WebClient();
wb.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wb_DownloadStringCompleted);
wb.DownloadStringAsync(new Uri("http://localhost/WhoTouches/ThreadSleep.aspx"));
}
void wb_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
Console.WriteLine("job is done now");
}
}
What I'm looking for is for a way to know when everything is done. I'm not sure how but I found the other day that if you used that WorkUnit inside a ASPX page it wouldn't finish the request until the async webclient call is complete. Point being, its possible but I dunno how.