0
当试图从使用此代码: LogicAppsAsyncResponseSample 我创造了这个方法,我最初的呼叫:资源组项目错误
public async Task<dynamic> InsertRecords943(string interchangeId, [FromBody] dynamic inputjson)
{
Guid id = Guid.NewGuid();
RunningTasks[id] = string.Empty;
new Thread(() => DoInsertRecords943(id, interchangeId, inputjson)).Start(); //Start the thread of work, but continue on before it completes
HttpResponseMessage responseMessage = Request.CreateResponse(HttpStatusCode.Accepted);
responseMessage.Headers.Add("location", String.Format("{0}://{1}/api/status/{2}", Request.RequestUri.Scheme, Request.RequestUri.Host, id));
responseMessage.Headers.Add("retry-after", "20");
return responseMessage;
}
但代码分析是生产这个错误:
错误CS1998这种异步方法缺少'等待'操作符并且会同步运行。考虑使用'await'操作符来等待非阻塞API调用,或者'等待Task.Run(...)'在后台线程上执行CPU绑定工作。
我也是想使方法同步:
public dynamic InsertRecords940(string interchangeId, [FromBody] dynamic inputjson)
或更换新的主题线路是:
await Task.Run(DoInsertRecords943(id, interchangeId, inputjson));
请问后来连工作,会不会仍然导致来电者超时?使其同步应该实际上工作。