小编SAB*_*lyu的帖子

HTTPClient每次返回相同的字符串

有人可以让我清楚为什么我的代码每次返回相同的字符串?

public MainPage()
{
    this.InitializeComponent();

    DispatcherTimer timer = new DispatcherTimer();
    timer.Interval = TimeSpan.FromSeconds(5);
    timer.Tick += OnTimerTick;
    timer.Start();
}

private void OnTimerTick(object sender, object e)
{
    getData();
    HubText.Text = dumpstr;
}

private async void getData()
{
    // Create an HttpClient instance
    HttpClient client = new HttpClient();
    var uri = new Uri("http://192.168.4.160:8081/v");
    try
    {
        // Send a request asynchronously continue when complete
        HttpResponseMessage response = await client.GetAsync(uri);
        // Check that response was successful or throw exception
        response.EnsureSuccessStatusCode();
        // Read response asynchronously
        dumpstr …
Run Code Online (Sandbox Code Playgroud)

c# wpf windows-store-apps

6
推荐指数
2
解决办法
4833
查看次数

标签 统计

c# ×1

windows-store-apps ×1

wpf ×1