G
Guest
I can't figure out why, in the following code, the exception is not caught
when EndIncoke is called in the callback handling method... any ideas?
Thanks in advance.
-Andrew
<snip>
static void DoIt()
{
Console.WriteLine("worker thread");
Thread.Sleep(1000);
Console.WriteLine("about to throw...");
Thread.Sleep(1000);
throw new Exception("EXCEPTION MSG");
}
static void Callback(IAsyncResult result)
{
MyDelegate d = (MyDelegate)result.AsyncState;
try
{
d.EndInvoke(result);
}
catch(Exception x)
{
Console.WriteLine(x.Message + " caught! ! !!");
}
}
static void Main(string[] args)
{
MethodInvoker del = DoIt;
del.BeginInvoke(new AsyncCallback(Callback), del);
Thread.CurrentThread.Join();
}
</snip>
when EndIncoke is called in the callback handling method... any ideas?
Thanks in advance.
-Andrew
<snip>
static void DoIt()
{
Console.WriteLine("worker thread");
Thread.Sleep(1000);
Console.WriteLine("about to throw...");
Thread.Sleep(1000);
throw new Exception("EXCEPTION MSG");
}
static void Callback(IAsyncResult result)
{
MyDelegate d = (MyDelegate)result.AsyncState;
try
{
d.EndInvoke(result);
}
catch(Exception x)
{
Console.WriteLine(x.Message + " caught! ! !!");
}
}
static void Main(string[] args)
{
MethodInvoker del = DoIt;
del.BeginInvoke(new AsyncCallback(Callback), del);
Thread.CurrentThread.Join();
}
</snip>