-
Notifications
You must be signed in to change notification settings - Fork 56
/
MainWindow.xaml.cs
35 lines (30 loc) · 910 Bytes
/
MainWindow.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System.Net.Http;
using System.Threading.Tasks;
using System.Windows;
namespace TplSchedulers
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private static readonly HttpClient w = new HttpClient();
private readonly TaskScheduler _uiScheduler =
TaskScheduler.FromCurrentSynchronizationContext();
private void FetchButtonClicked(object sender, RoutedEventArgs e)
{
string url = "https://endjin.com/";
Task<string> webGetTask = w.GetStringAsync(url);
webGetTask.ContinueWith(t =>
{
string webContent = t.Result;
outputTextBox.Text = webContent;
},
_uiScheduler);
}
}
}