【发布时间】:2016-12-22 23:40:35
【问题描述】:
我陷入了异步死锁,无法找出修复它的正确语法。我查看了几种不同的解决方案,但似乎无法完全弄清楚导致问题的原因。
我使用Parse 作为后端并尝试使用处理程序写入表。我的处理程序看起来像:
public class VisitorSignupHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
//Get the user's name and email address
var UserFullName = context.Request.QueryString["name"].UrlDecode();
var UserEmailAddress = context.Request.QueryString["email"].UrlDecode();
//Save the user's information
var TaskToken = UserSignup.SaveUserSignup(UserFullName, UserEmailAddress);
TaskToken.Wait();
....
}
public bool IsReusable { get { return false; } }
}
然后它调用我的中间层:
public static class UserSignup
{
public static async Task SaveUserSignup(string fullName, string emailAddress)
{
//Initialize the Parse client with the Application ID and the Windows key
ParseClient.Initialize(AppID, Key);
//Create the object
var UserObject = new ParseObject("UserSignup")
{
{"UserFullName", fullName},
{"UserEmailAddress", emailAddress}
};
//Commit the object
await UserObject.SaveAsync();
}
}
虽然这似乎卡在Wait()。我的印象是Wait() 只会等待任务完成,然后返回正常操作。这不正确吗?
【问题讨论】:
标签: .net async-await parse-platform ihttphandler