Responsive interfaces
The interfaces used in all the examples so far used short-running commands that have no significant impact on the user interface.
If an event handler in the user interface carries out a longer-running activity, the entire interface will freeze. This problem is simulated by using Start-Sleep in the following example:
$xaml = '<?xml version="1.0" encoding="utf-8"?> <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="350" Height="350"> <Button Name="Button" Content="Start" /> </Window>' $ui = Import-Xaml $xaml $ui.Controls['Button'].add_Click({ param ( $sender, $eventArgs ) Start-Sleep -Seconds 10 }) $ui.MainWindow.ShowDialog() Once the button is clicked, the user interface will freeze. It is not possible to move or close the window...