Skip to content

Instantly share code, notes, and snippets.

@wldevries
Created September 4, 2015 16:13
Show Gist options
  • Save wldevries/7bbdfebd8fa83cbfaad1 to your computer and use it in GitHub Desktop.
Save wldevries/7bbdfebd8fa83cbfaad1 to your computer and use it in GitHub Desktop.
using System;
using System.Threading.Tasks;
namespace Microsoft.Practices.Prism.Interactivity.InteractionRequest
{
public static class InteractionRequestMixins
{
public static async Task<T> RaiseAsync<T>(this InteractionRequest<T> request, T context) where T : INotification
{
return await AwaitCallbackResult<T>(callback => request.Raise(context, callback));
}
private static async Task<TResult> AwaitCallbackResult<TResult>(Action<Action<TResult>> f)
{
var tcs = new TaskCompletionSource<TResult>();
f(n => tcs.SetResult(n));
return await tcs.Task;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment