销毁异步虚空

时间:2018-10-06 19:20:14

标签: c# xamarin

我正在使用Xamarin和C#。当我销毁一个活动时,我发现异步void仍在运行。

protected override void OnCreate(Bundle savedInstanceState)
{
    base.OnCreate(savedInstanceState);

    SetContentView(Resource.Layout.TableItemsMain);
    RefreshTableAsync();
}

async Task RefreshTableAsync()
{
    using (var client = new HttpClient())
    {
        client.Timeout = TimeSpan.FromMilliseconds(10000);
        var response = await client.PostAsync("http://" + MyIp + ":9090/", new StringContent("2:" + MyTableName + "", Encoding.UTF8, "application/json"));

        if (response.IsSuccessStatusCode)
        {
            string content = await response.Content.ReadAsStringAsync();

        }
    }
}

如何在销毁时处置异步空隙?

0 个答案:

没有答案