Skip to content

Instantly share code, notes, and snippets.

@aliabidzaidi
Created June 1, 2019 19:07
Show Gist options
  • Save aliabidzaidi/d94607a7db39c90c9fc88403195f33c2 to your computer and use it in GitHub Desktop.
Save aliabidzaidi/d94607a7db39c90c9fc88403195f33c2 to your computer and use it in GitHub Desktop.
Creating & Executing Tasks Lazily
Lazy<Task<string>> lazyTask = new Lazy<Task<string>>(() =>
Task<string>.Factory.StartNew(() =>
{
Console.WriteLine("Task Body Working .....");
return "TaskBody Result";
})
);
Console.WriteLine("Accessing lazy Task Result {0}", lazyTask.Value.Result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment