private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
 {
     if (e.ExceptionObject is Exception ex)
     {
         ApplicationInsightHelper.TrackException("UnhandledException detected.", ex);
     }
     else
     {
         ApplicationInsightHelper.TrackException("UnhandledException detected. (The ExceptionObject was not a Exception)", new Exception("The ExceptionObject was not a Exception, dont know what went wrong."));
     }
     FlushAndWait(sender, e);
 }
 private static void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
 {
     ApplicationInsightHelper.TrackException("TaskScheduler_UnobservedTaskException", e.Exception);
 }