Skip to content

Instantly share code, notes, and snippets.

@pablocar80
Created October 9, 2019 17:36
Show Gist options
  • Save pablocar80/17dacbd5d87af6dfa8724980b9268bab to your computer and use it in GitHub Desktop.
Save pablocar80/17dacbd5d87af6dfa8724980b9268bab to your computer and use it in GitHub Desktop.
async interface c#
interface IOperator
{
Task Execute();
}
class FileWriter : IOperator // async implementation
{
public async Task Execute()
{
await File.WriteAllTextAsync("myfile1.txt", "hello");
await File.WriteAllTextAsync("myfile2.txt", "bye");
}
}
class DoNothing : IOperator // sync implementation
{
public Task Execute()
{
return Task.CompletedTask;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment