File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -77,6 +77,12 @@ private async Task TaskProcessing(CancellationToken cancellationToken)
7777 if ( _log )
7878 _logger . LogDebug ( "~~ QueuedHostedService: Completed Task: {item}" , workItemName ) ;
7979 }
80+ catch ( OperationCanceledException ) when ( cancellationToken . IsCancellationRequested )
81+ {
82+ // Ignore cancellation exception during shutdown if no task was being processed
83+ if ( workItem != null )
84+ _logger . LogError ( "~~ QueuedHostedService: Task was cancelled while executing!: {item}" , workItem ? . Method . GetSignature ( ) ) ;
85+ }
8086 catch ( Exception ex )
8187 {
8288 _logger . LogError ( ex , "~~ QueuedHostedService:: Error executing Task: {item}" , workItem ? . Method . GetSignature ( ) ) ;
@@ -111,6 +117,12 @@ private async Task ValueTaskProcessing(CancellationToken cancellationToken)
111117 if ( _log )
112118 _logger . LogDebug ( "~~ QueuedHostedService: Completed ValueTask: {item}" , workItemName ) ;
113119 }
120+ catch ( OperationCanceledException ) when ( cancellationToken . IsCancellationRequested )
121+ {
122+ // Ignore cancellation exception during shutdown if no ValueTask was being processed
123+ if ( workItem != null )
124+ _logger . LogError ( "~~ QueuedHostedService: ValueTask was cancelled while executing!: {item}" , workItem ? . Method . GetSignature ( ) ) ;
125+ }
114126 catch ( Exception ex )
115127 {
116128 _logger . LogError ( ex , "~~ QueuedHostedService: Error executing ValueTask: {item}" , workItem ? . Method . GetSignature ( ) ) ;
You can’t perform that action at this time.
0 commit comments