Skip to content

Commit f201804

Browse files
committed
Catch TaskCancelledException when disposing TinyMessageBus
The receiver task may be cancelled so this exception must be caught.
1 parent 008094d commit f201804

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/TinyIpc/Messaging/TinyMessageBus.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,14 @@ protected virtual void Dispose(bool disposing)
137137
receiverChannel.Value.Writer.Complete();
138138
}
139139

140-
receiverTask.ConfigureAwait(false).GetAwaiter().GetResult();
140+
try
141+
{
142+
receiverTask.ConfigureAwait(false).GetAwaiter().GetResult();
143+
}
144+
catch (TaskCanceledException)
145+
{
146+
// Expected
147+
}
141148

142149
if (disposeFile && memoryMappedFile is IDisposable disposableFile)
143150
{

0 commit comments

Comments
 (0)