Microsoft Bot Framework C# 异步问题

Microsoft Bot Framework C# Async Issues

我遇到一个函数未被调用的问题。我的猜测是这是一个同步问题。

代码如下:

await context.PostAsync("Foo Bar");

如果我把它放在POST之前或之后到网络服务器,下面的函数似乎不会被调用。

context.Call(new QuestionFourDialog(), this.QuestionFourResumeAfter);

Uri baseUri = new Uri("http://somedomain.com/");
UriBuilder builder = new UriBuilder($"{baseUri}/analytics/message?");

using (WebClient webclient = new WebClient())
{
    webclient.Encoding = System.Text.Encoding.UTF8;
    webclient.Headers.Add("Content-Type", "application/json");

    string postBody = $"{{\"message\": \"{this.answer}\", \"key\": \"7F02D18E-88E7-486D-B51F-550118491CB1\"}}";

    webclient.UploadString(builder.Uri, postBody);
}

有没有办法调用 POST 代码异步或其他方法来解决这个问题?

我替换了这一行

webclient.UploadString(builder.Uri, postBody);

webclient.UploadStringAsync(builder.Uri, postBody);

现在完美运行了。