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"); |
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
class Test | |
{ | |
// Synchronous version | |
public string MySyncFunction() | |
{ | |
string text = File.ReadAllText("myfile.txt"); | |
return text; | |
} | |
// Asynchronous version. Notice ‘async Task’ and ‘await’. |