我的问题是,在Azure存储表上调用await table.ExecuteAsync(...)可以插入所请求的数据,但从未完成(不返回TableResult)。对于InsertOrUpdate和Update操作也是同样的情况。我还尝试了具有不同属性数量的不同表格 - 仍然存在相同的问题。
当我调用table.Execute(...)时 - 对于每种操作都能正常工作。
以下是我的代码 - 就这么简单:
外部调用(它位于MVC控制器中的异步操作中):
当我调用table.Execute(...)时 - 对于每种操作都能正常工作。
以下是我的代码 - 就这么简单:
外部调用(它位于MVC控制器中的异步操作中):
List<Task<ServiceResult<Boolean?>>> addPostTasks = new List<Task<Common.ServiceResult<bool?>>>();
foreach (var userStream in userStreams)
{
Task<ServiceResult<Boolean?>> addPostTask = postsStorageSvc.AddImagePost(...);
postsAddImagePostTasks.Add(addPostTask);
}
Task.WaitAll(addPostTasks.ToArray());
调用的方法:
public async Task<ServiceResult<Boolean?>> AddImagePost(...)
{
ServiceResult<Boolean?> result = new ServiceResult<bool?>(null);
try
{
PostTableEntity newPost = new PostTableEntity(streamId.ToString(), Guid.NewGuid().ToString(), creatorId, date, htmlText);
TableOperation insertOperation = TableOperation.Insert(newPost);
//Following line never ends!
TableResult tableResult = await this._storageTableBootstrapper.Table.ExecuteAsync(insertOperation);
//Following line works perfect - but is not ASYNC
TableResult tableResult = this._storageTableBootstrapper.Table.Execute(insertOperation);
}
catch (Exception ex)
{
result.Result = false;
result.Errors.Add("AzurePostsStorageService Unexpected error: " + ex.Message);
}
return result;
}
Task.Result
或Task.Wait
时被阻塞了? - Yuval Itzchakov