Can anyone explain why I am not getting an exception from the hit code:
Action <Exception> myact = ( ) => { throw new Exception( "test" ); }; Task myactTask = Task.Factory.StartNew( ( ) => myact); try { myactTask.Wait( ); Console.WriteLine( myactTask.Id.ToString( ) ); Console.WriteLine( myactTask.IsCompleted.ToString( ) ); } catch( AggregateException ex ) { throw ex; }
on the other hand, if you replace the action "myact" with the method "myact ()", then I can get an exception and it can be handled using the catch catch block.
public static void myact( ) { throw new Exception( "test" ); }
source share