I need load a overlay on a WPF wizardcontrol. I am using a busyIndicator tool from the wpf extended tooklit.
The code for async await works but the gui thread locks . I am trying add a please wait message when the await calls the function
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;
}
The XAML for the BusyIndicator is as below.
<xctk:BusyIndicator x:Name="BusyIndicator" IsBusy="False" BusyContent="Please Wait">
</xctk:BusyIndicator>
The LonRunningFunction is a Webservice call which does not update the UI only returns a Bool value
public static bool LongRunningFunction(string URL)
{
bool IsPresent = CallWebservice()
return IsPresent;
}
Issue
1) The BusyIndicator does not seem to fire before the async call instead it seems to be fire when the LongRunning task completes
2) What is the correct process to call a gui overlay when async and await is used.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…