Exemple #1
0
 public static void SafeRun(Func <Task> action, IMetricsService metricService, string response, MessageEventArgs request)
 {
     Task.Run(async() => {
         IMetrics metrics = null;
         try {
             await action.Invoke();
         } catch (Exception e) {
             metrics = metricService.CreateMetricsFrom(response, request);
             Settings.Logger.Error(e, metrics);
         }
         metrics ??= metricService.CreateMetricsFrom(response, request);
         Settings.Logger.Trace("Task completed successfully:\n", metrics);
     });
 }