public async Task ExecuteAsync(Func <Task> action, string text) { try { LongOperationTextChanged?.Invoke(text); LongOperationProgressChanged?.Invoke(true); await Task.Run(action); } catch (Exception ex) { LongOperationExceptioned?.Invoke(ex); } finally { LongOperationProgressChanged?.Invoke(false); } }
public async Task <T> ExecuteAsync <T>(Func <T> action, string text) { T result = default; try { LongOperationTextChanged?.Invoke(text); LongOperationProgressChanged?.Invoke(true); result = await Task.Run(action); } catch (Exception ex) { LongOperationExceptioned?.Invoke(ex); } finally { LongOperationProgressChanged?.Invoke(false); } return(result); }