Grid filtering throws 'System.OperationCanceledException' in System.Private.CoreLib.dll #630
-
I have just implemented filtering on an HxGrid with the following code:
When using the filter function, I am getting tons of OperationCanceledException thrown in the logs, although the functionality appears to be working fine. TIA for the assistance. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Not sure what you mean by "in the logs", but Ideally, you should pass the For more details refer to https://learn.microsoft.com/en-us/dotnet/standard/threading/cancellation-in-managed-threads |
Beta Was this translation helpful? Give feedback.
-
I actually refactored the code so that GetOptOutDonorsAsync() is no longer called from the Grid data method, as I realized this combined with the filter function was really thrashing the database with many needless requests as well as causing the above mentioned exception to be thrown. Thank you and I apologize for bothering you unneccessarily. |
Beta Was this translation helpful? Give feedback.
Not sure what you mean by "in the logs", but
OperationCanceledException
is a regular outcome of usingCancelationToken
s and canceling the operation. For example, when you are scrolling the grid, theDataProvider
gets called for visible ranges of items. When you scroll to another part of the dataset while the originalDataProvider
-request is still running, it gets canceled.Ideally, you should pass the
CancelationToken
to yourGetOptOutDonorsAsync()
asDonorService.GetOptOutDonorsAsync(requrest.CancelationToken)
and allow it to cancel the async operation in its own way (ie. by passing theCancelationToken
to underlying Entity Framework call or similar infrastructure code).For more details…