Skip to content

Instantly share code, notes, and snippets.

@iamsunny
Last active March 12, 2018 08:05
Show Gist options
  • Save iamsunny/85934386d17a87c8a815a6527c86b4c7 to your computer and use it in GitHub Desktop.
Save iamsunny/85934386d17a87c8a815a6527c86b4c7 to your computer and use it in GitHub Desktop.
C# Class with an Async Method
class AsyncMethods
{
/// <param name="sleepTime">sleep time in seconds</param>
public async Task<bool> SleepAsync(int sleepTime)
{
Console.WriteLine($"SleepAsync for {sleepTime} seconds starts");
await Task.Delay(sleepTime*1000);
Console.WriteLine($"SleepAsync for {sleepTime} seconds completes");
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment