Last active
August 29, 2015 14:06
-
-
Save alextercete/f34691cb9e4df4d2e78b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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