Exemplo n.º 1
0
 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);
     }
 }
Exemplo n.º 2
0
        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);
        }