Skip to content

Instantly share code, notes, and snippets.

@alextercete
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alextercete/f34691cb9e4df4d2e78b to your computer and use it in GitHub Desktop.
Save alextercete/f34691cb9e4df4d2e78b to your computer and use it in GitHub Desktop.
using System;
using System.Threading.Tasks;
namespace AsyncAndAwaitSecrets.Samples
{
public interface IAsynchronousProgrammingModel<T>
{
IAsyncResult BeginSomething(AsyncCallback callback, object state);
T EndSomething(IAsyncResult result);
}
public class AsynchronousProgrammingModelWrapper<T>
{
private readonly IAsynchronousProgrammingModel<T> _apm;
public AsynchronousProgrammingModelWrapper(IAsynchronousProgrammingModel<T> apm)
{
_apm = apm;
}
public Task<T> SomethingAsync()
{
return Task.Factory.FromAsync<T>(_apm.BeginSomething, _apm.EndSomething, null);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment