Skip to content

Commit 3025cbf

Browse files
committed
Move object disposal
1 parent df6f60f commit 3025cbf

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Source/HiveMQtt/Client/Connection/ConnectionManager.cs

+4
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,10 @@ internal async Task CancelBackgroundTasksAsync()
197197
/// </summary>
198198
public void Dispose()
199199
{
200+
// Dispose managed resources.
201+
this.cancellationTokenSource.Cancel();
202+
this.cancellationTokenSource.Dispose();
203+
200204
this.Dispose();
201205
/*
202206
This object will be cleaned up by the Dispose method.

Source/HiveMQtt/Client/HiveMQClientUtil.cs

+1-5
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,7 @@ protected virtual void Dispose(bool disposing)
173173
Logger.Trace("HiveMQClient Dispose: Disconnecting connected client.");
174174
_ = Task.Run(async () => await this.DisconnectAsync().ConfigureAwait(false));
175175
}
176-
177-
// Dispose managed resources.
178-
// this.cancellationTokenSource.Cancel();
179-
// this.cancellationTokenSource.Dispose();
180-
}
176+
}
181177

182178
// Call the appropriate methods to clean up
183179
// unmanaged resources here.

0 commit comments

Comments
 (0)