Custom Busy Overlay für WPF WizardControl unter Verwendung von async await
Ich muss ein Overlay für ein WPF-Assistentensteuerelement laden. Ich verwende ein busyIndicator-Tool aus dem erweiterten Wpf-Takedlit.
Der Code für async await funktioniert, aber der GUI-Thread wird gesperrt. Ich versuche, eine Bitte warten-Nachricht hinzuzufügen, wenn das Warten die Funktion @ aufruf
private async void Button1_Click(object sender, RoutedEventArgs e)
{
BusyIndicator.IsBusy = true;
BusyIndicator.IsEnabled = true;
BusyIndicator.BusyContent = "Please wait while Site is provisioned";
await Task.Run(() =>
{
LongRunningFunction();
});
BusyIndicator.IsBusy=false;
}
Die XAML für den BusyIndicator ist wie folgt.
<xctk:BusyIndicator x:Name="BusyIndicator" IsBusy="False" BusyContent="Please Wait">
</xctk:BusyIndicator>
Die LonRunningFunction ist ein Webservice-Aufruf, der die Benutzeroberfläche nicht aktualisiert und nur einen Bool-Wert zurückgibt.
public static bool LongRunningFunction(string URL)
{
bool IsPresent = CallWebservice()
return IsPresent;
}
Proble
1) Der BusyIndicator scheint nicht vor dem asynchronen Aufruf ausgelöst zu werden, sondern scheint ausgelöst zu werden, wenn der LongRunning-Task abgeschlossen ist
2) Wie wird ein GUI-Overlay korrekt aufgerufen, wenn async and await verwendet wird?