Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Multithreading 资源组项目错误_Multithreading_Asp.net Web Api_Azure Logic Apps - Fatal编程技术网

Multithreading 资源组项目错误

Multithreading 资源组项目错误,multithreading,asp.net-web-api,azure-logic-apps,Multithreading,Asp.net Web Api,Azure Logic Apps,尝试从以下位置使用此代码时: 我为我的初始调用创建了此方法: public async Task<dynamic> InsertRecords943(string interchangeId, [FromBody] dynamic inputjson) { Guid id = Guid.NewGuid(); RunningTasks[id] = string.Empty; new Thread(() => DoIn

尝试从以下位置使用此代码时: 我为我的初始调用创建了此方法:

    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;
    }
或将新螺纹线更改为:

await Task.Run(DoInsertRecords943(id, interchangeId, inputjson));

后者会工作吗?它不会仍然导致调用方超时吗?使其同步实际上应该是可行的。

是的,好的捕获-您可能希望使方法同步-因为等待将使操作同步执行我们不希望的“长时间运行步骤”

希望这是有意义的-如果它能工作,LMK和我将修复我的代码:)

await Task.Run(DoInsertRecords943(id, interchangeId, inputjson));