我正在使用Azure Search .Net SDK。任务被取消 - 这是什么意思?
我打电话同步(不是异步)函数是这样的:
var searchResults = searchIndexClient.Documents.Search<T>(searchText, searchParameters);
它通常工作。我没有使用任何异步函数,但不知何故错误我刚刚看起来像一个异步错误:
System.Threading.Tasks.TaskCanceledException: A task was canceled.
CancellationToken: IsCanceleationRequested=false
Task: Id = 556, Status = Canceled, Method = "{null}", Result = "{Not yet computed}"
StackTrace:
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable
1.ConfiguredTaskAwaiter.GetResult() at Microsoft.Azure.Search.DocumentsOperations.<DoContinueSearchWithHttpMessagesAsync>d__15
3.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult() at Microsoft.Azure.Search.DocumentsOperationsExtensions.<SearchAsync>d__15
1.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at Microsoft.Azure.Search.DocumentsOperationsExtensions.Search[T](IDocumentsOperations operations, String searchText, SearchParameters searchParameters, SearchRequestOptions searchRequestOptions) at MyApp.AzureSearch.AzureSearchService.PerformSearch[T](String searchText, SearchParameters searchParameters) in c:\Projects\MyAppServer\src\MyApp.AzureSearch\AzureSearchService.cs:line 359 at MyApp.AzureSearch.AzureSearchService.Search[T](String searchText, List
1 searchFields, SearchMode searchMode, List1 select, Nullable
1 skip, Nullable1 top, String filter, Boolean includeTotalResultCount, List
1 orderBy) in c:\Projects\MyAppServer\src\MyApp.AzureSearch\AzureSearchService.cs:line 262 at MyApp.AzureSearch.AzureSearchService.SearchEmails(Guid userId, String origin, String searchText, Nullable1 skip, Nullable
1 top, Boolean includeTotalResultCount, Boolean includeHtmlBody, Boolean orderByProcessedAscending, String interactionStatus) in c:\Projects\MyAppServer\src\MyApp.AzureSearch\AzureSearchService.cs:line 167 at MyApp.Domain.MyAppMessages.Command.MyAppMessagesAllNoticedUpdater.Handle(VisitorSession userSession, NoticeAllMyAppMessages processCommand) in c:\Projects\MyAppServer\src\MyApp.Domain\MyAppMessages\Command\MyAppMessagesAllNoticedUpdater.cs:line 30
谢谢,我想它只是包装一个异步功能。它根本不是一个复杂的查询,查询中的数据也很少。我没想到.net SDK会抛出错误,除非在查询中配置错误。是否有我可以处理的.net sdk可能引发的所有可能的错误列表? – richard
可以抛出的主要异常是:'CloudException','IndexBatchException'(仅用于索引),'ValidationException',当然还有'OperationCanceledException'(或其子类'TaskCanceledException'你正在处理这里)。但是由于C#不是检查的异常语言,您可能也会看到其他异常(如ArgumentException)。 –