Performs / catches work outside of Task.Factory.StartNew?

Will the following exception occur inside StartNew ()? This does not seem to be the case.

   try
   {
      Task.Factory.StartNew(() =>
      {
       //do something
      });
    }
    catch(Exception ex)
    {
      //log it
    }
+4
source share
2 answers

No. Your try block will be completed after creating a new task.

However, you can catch the exceptions. Please see: Error using Task.Factory for more information.

+3
source

This is not possible because when the function is trycompleted, the task is not yet completed. There is no way to know if an exception will occur in the future or not.

The whole point of the task is to start asynchronous independent computing.

0
source

All Articles