Skip to content

Instantly share code, notes, and snippets.

@tugberkugurlu
Created July 22, 2012 14:16
Show Gist options
  • Save tugberkugurlu/3159836 to your computer and use it in GitHub Desktop.
Save tugberkugurlu/3159836 to your computer and use it in GitHub Desktop.
public class AsyncFactory {
public static Task<int> GetIntAsync() {
var tcs = new TaskCompletionSource<int>();
var timer = new System.Timers.Timer(2000);
timer.AutoReset = false;
timer.Elapsed += (s, e) => {
tcs.SetResult(10);
timer.Dispose();
};
timer.Start();
return tcs.Task;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment