/// <summary> /// Call from Ui thread /// </summary> public async Task <T> ExecuteAsync <T>(Func <T> func) { Debug.Assert(Thread.CurrentThread.ManagedThreadId == Application.Current.Dispatcher.Thread.ManagedThreadId); var result = default(T); Exception exception = null; using (var progress = _progressService.CreateProgress()) { try { result = await Task.Run(func).ConfigureAwait(true); } catch (Exception ex) { exception = ex; } } if (exception != null) { _dialogs.ShowError(exception.Message); } return(result); }
/// <summary> /// Call from Ui thread /// </summary> public async Task <T> ExecuteAsync <T>(Func <T> func) { Debug.Assert(Thread.CurrentThread.ManagedThreadId == Application.Current.Dispatcher.Thread.ManagedThreadId); var result = default(T); Exception exception = null; using (var progress = _progressService.CreateProgress()) { try { result = await Task.Run(func).ConfigureAwait(true); } catch (Exception ex) { exception = ex; } } if (exception != null) { var message = exception.Message; if (exception is KeyNotFoundException) { // For example mismatch between the existence of a local file and the existence in source control. message += "\nSure the local repository is up to date?"; } _dialogs.ShowError(message); } return(result); }