Skip to content

Instantly share code, notes, and snippets.

View pablocar80's full-sized avatar

Pablo Carbonell pablocar80

View GitHub Profile
@pablocar80
pablocar80 / AsyncInterface.cs
Created October 9, 2019 17:36
async interface c#
interface IOperator
{
Task Execute();
}
class FileWriter : IOperator // async implementation
{
public async Task Execute()
{
await File.WriteAllTextAsync("myfile1.txt", "hello");
@pablocar80
pablocar80 / AsyncExample.cs
Last active October 9, 2019 17:21
converting synchronous function
class Test
{
// Synchronous version
public string MySyncFunction()
{
string text = File.ReadAllText("myfile.txt");
return text;
}
// Asynchronous version. Notice ‘async Task’ and ‘await’.