DEV Community

Discussion on: WPF DataGrid Binding

Collapse
 
jwp profile image
John Peters

Ah yes Sebastian; I forgot about the ICommand and it's RelayCommand brother. Thanks for reminder!

If we make our eventHandlers async, and put in code like this:

await Task.Run(() =>
{
    var proc = Process.GetProcessById(id);
    proc.Kill();
});
// this won't run until await is done.
this.RefreshView();

Enter fullscreen mode Exit fullscreen mode

The GUI Will never freeze and the next statement after the await doesn't execute until the Task is done! Kind of like a built in state machine for the button and the view.