diff --git a/Tapeti/Config/IMessageContext.cs b/Tapeti/Config/IMessageContext.cs
index ac6a0e5..7d2db6d 100644
--- a/Tapeti/Config/IMessageContext.cs
+++ b/Tapeti/Config/IMessageContext.cs
@@ -8,7 +8,7 @@ namespace Tapeti.Config
///
/// Provides information about the message currently being handled.
///
- public interface IMessageContext : IAsyncDisposable, IDisposable
+ public interface IMessageContext : IAsyncDisposable
{
///
/// Provides access to the Tapeti config.
diff --git a/Tapeti/Default/MessageContext.cs b/Tapeti/Default/MessageContext.cs
index 6a001af..40a153c 100644
--- a/Tapeti/Default/MessageContext.cs
+++ b/Tapeti/Default/MessageContext.cs
@@ -66,21 +66,21 @@ namespace Tapeti.Default
}
- ///
- public void Dispose()
- {
- foreach (var payload in payloads.Values)
- (payload as IDisposable)?.Dispose();
- }
-
-
///
public async ValueTask DisposeAsync()
{
foreach (var payload in payloads.Values)
{
- if (payload is IAsyncDisposable asyncDisposable)
- await asyncDisposable.DisposeAsync();
+ switch (payload)
+ {
+ case IAsyncDisposable asyncDisposable:
+ await asyncDisposable.DisposeAsync();
+ break;
+
+ case IDisposable disposable:
+ disposable.Dispose();
+ break;
+ }
}
}