Skip to content

Commit

Permalink
Return proper result from execute on ui
Browse files Browse the repository at this point in the history
  • Loading branch information
ayende committed Dec 14, 2011

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 29d0fa4 commit 6719014
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Raven.Studio/Infrastructure/Execute.cs
Original file line number Diff line number Diff line change
@@ -17,18 +17,25 @@ public static Task OnTheUI(Action action)
if (Deployment.Current.Dispatcher.CheckAccess())
{
action();
return null;
return EmptyResult<object>();
}
return Deployment.Current.Dispatcher.InvokeAsync(action)
.Catch();
}

private static Task<T> EmptyResult<T>()
{
var tcs = new TaskCompletionSource<T>();
tcs.SetResult(default(T));
return tcs.Task;
}

public static Task<TResult> OnTheUI<TResult>(Func<TResult> action)
{
if (Deployment.Current.Dispatcher.CheckAccess())
{
action();
return null;
return EmptyResult<TResult>();
}
return Deployment.Current.Dispatcher.InvokeAsync(action)
.Catch();

0 comments on commit 6719014

Please sign in to comment.