Created
October 9, 2019 17:36
-
-
Save pablocar80/17dacbd5d87af6dfa8724980b9268bab to your computer and use it in GitHub Desktop.
async interface c#
This file contains hidden or 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
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