Skip to content

Commit

Permalink
Merge pull request #6432 from dotnet/main
Browse files Browse the repository at this point in the history
  • Loading branch information
BillWagner authored Nov 29, 2023
2 parents d921987 + be1699b commit d0e1262
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
Binary file modified wpf/Threading/Weather/net48/csharp/Code.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion wpf/Threading/Weather/net48/csharp/Weather.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ private async void FetchButton_Click(object sender, RoutedEventArgs e)
((Storyboard)Resources["HideWeatherImageStoryboard"]).Begin(this);

// Asynchronously fetch the weather forecast on a different thread and pause this code.
string weather = await FetchWeatherFromServerAsync();
string weather = await Task.Run(FetchWeatherFromServerAsync);

// After async data returns, process it...
// Set the weather image
Expand Down
Binary file modified wpf/Threading/Weather/net48/vb/Code.zip
Binary file not shown.
8 changes: 4 additions & 4 deletions wpf/Threading/Weather/net48/vb/Weather.xaml.vb
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ Public Class Weather
DirectCast(Resources("HideWeatherImageStoryboard"), Storyboard).Begin(Me)

' Asynchronously fetch the weather forecast on a different thread and pause this code.
Dim Weather As String = Await FetchWeatherFromServerAsync()
Dim weatherType As String = Await Task.Run(AddressOf FetchWeatherFromServerAsync)

' After async data returns, process it...
' Set the weather image
If Weather = "sunny" Then
If weatherType = "sunny" Then
weatherIndicatorImage.Source = DirectCast(Resources("SunnyImageSource"), ImageSource)

ElseIf Weather = "rainy" Then
ElseIf weatherType = "rainy" Then
weatherIndicatorImage.Source = DirectCast(Resources("RainingImageSource"), ImageSource)

End If
Expand All @@ -30,7 +30,7 @@ Public Class Weather
' Update UI text
fetchButton.IsEnabled = True
fetchButton.Content = "Fetch Forecast"
weatherText.Text = Weather
weatherText.Text = weatherType
End Sub

Private Async Function FetchWeatherFromServerAsync() As Task(Of String)
Expand Down

0 comments on commit d0e1262

Please sign in to comment.