Add a C# snippet for async tasks being run from the UI

This commit is contained in:
Théo Marchal 2023-03-15 18:16:40 +01:00
parent 193da79f3d
commit 4ecfc1fb9f

16
async-from-ui.cs Normal file
View File

@ -0,0 +1,16 @@
// Basic function handling to having async tasks being run from an interface action in C# WPF.
private async void Clicked(object sender, RoutedEventArgs e)
{
await Function();
}
public async Task Function()
{
await Task.Run(async () =>
{
await someCommand();
});
UI_things();
}