Add a C# snippet for async tasks being run from the UI
This commit is contained in:
parent
193da79f3d
commit
4ecfc1fb9f
16
async-from-ui.cs
Normal file
16
async-from-ui.cs
Normal 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();
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user