所以,我有一个Web API操作,它执行一个异步函数。
public void Post([FromBody]InsertRequest request)
{
InsertPostCommand.Execute(request);
DoAsync();
}
private async void DoAsync()
{
await Task.Run(() =>
{
//do async stuff here
});
}
我希望控制器动作在异步操作执行时返回给客户端。
我这样做,但是出现了异常:
System.InvalidOperationException: An asynchronous module or handler completed while an asynchronous operation was still pending.
请问我该怎么做?谢谢。