Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/13.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
Azure CloudTable.ExecuteAsync超时时的句柄_Azure_Azure Storage_Azure Table Storage - Fatal编程技术网

Azure CloudTable.ExecuteAsync超时时的句柄

Azure CloudTable.ExecuteAsync超时时的句柄,azure,azure-storage,azure-table-storage,Azure,Azure Storage,Azure Table Storage,我有以下代码: var operation = TableOperation.InsertOrReplace(entity); var options = new TableRequestOptions { MaximumExecutionTime = TimeSpan.FromSeconds(10) }; var context = new OperationContext(); var result = await table.ExecuteAsync(ope

我有以下代码:

var operation = TableOperation.InsertOrReplace(entity);                
var options = new TableRequestOptions { MaximumExecutionTime = TimeSpan.FromSeconds(10) };
var context = new OperationContext();
var result = await table.ExecuteAsync(operation, options, context);
正如你所看到的,我已经设定在10秒后放弃

当它达到极限时,上面的第四行显然抛出了一个NullReferenceException

我不想抓住那个例外

处理这个问题的最佳方法是什么

也许我可以检查任务而不是等待

或者可能在OperationContext上有什么东西

使用StackTrace进行更新-不需要进行太多操作

System.NullReferenceException:
   at Save.Save+<SaveEntity>d__3.MoveNext (Save, Version=1.0.0.0, Culture=neutral, PublicKeyToken=nullSave, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: E:\Code\Save\Save.csSave, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: 164)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Save.Save+<Run>d__2.MoveNext (Save, Version=1.0.0.0, Culture=neutral, PublicKeyToken=nullSave, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: E:\Code\Save\Save.csSave, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: 92)
System.NullReferenceException:
在Save.Save+d__3.MoveNext(Save,版本=1.0.0,区域性=neutral,PublicKeyToken=nullSave,版本=1.0.0.0,区域性=nullSave,版本=1.0.0,PublicKeyToken=nural,PublicKeyToken=null:E:\Code\Save\Save.csSave,版本=1.0.0.0.0,区域性=neutral,PublicKeyToken=null:164)
在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(System.Private.CoreLib,版本=4.0.0.0,区域性=中立,PublicKeyToken=7cec85d7bea7798e)
在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Private.CoreLib,版本=4.0.0.0,区域性=neutral,PublicKeyToken=7cec85d7bea7798e)
在Save.Save+d__2.MoveNext(保存,版本=1.0.0.0,区域性=中性,PublicKeyToken=nullSave,版本=1.0.0.0,区域性=中性,PublicKeyToken=null:E:\Code\Save\Save.csSave,版本=1.0.0.0,区域性=中性,PublicKeyToken=null:92)

不太明白您到底想做什么。你能详细说明一下吗?是的。我希望在达到超时时捕获,并向调用方返回一个更可控的响应。有时它会抛出带有特定状态代码的StorageException,但有时它会抛出NullReferenceException。我已经读到,如果该方法意外返回null,那么这可能会作为wait的一部分发生。Hmmm…当您得到
NullReferenceException
时,它是否会告诉您它得到的变量是什么?理想情况下,您应该始终返回
StorageException
。如果可能的话,还可以共享堆栈跟踪。我添加了StackTraceIt,看起来您编写了自己的类来保存一个行为不正常的实体。您可能还需要为此添加代码。