/// <summary> /// Executes the in safe context. /// </summary> /// <typeparam name="T"></typeparam> /// <typeparam name="TV">The type of the V.</typeparam> /// <param name="functor">The functor.</param> /// <param name="t">The t.</param> /// <returns></returns> private TV ExecuteInSafeContext <T, TV>(Func <T, TV> functor, T t) { var retval = default(TV); try { retval = functor.Invoke(t); } catch (Exception ex) { Logger.Log(ex); throw; } return(retval); }
protected override void OnSampleError(Exception ex) { _logger.Log <LocalFixedDiskUsageSampler>( LogType.Error, "Error whilst attempting disk usage sampling", ex); }
protected override void OnSampleError(Exception ex) { _logger.Log <CpuUsageSampler>( LogType.Error, "Error whilst attempting CPU sampling", ex); }
private Task TryDispose( IDisposable disposable, string label) { return(Task.Run(() => { try { disposable?.Dispose(); } catch (Exception ex) { _logger.Log <SystemStatsProvider>( LogType.Error, $"Unable to dispose {label}", ex ); } })); }