Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion Sources/Core/OutWit.Database.Core/Mvcc/MvccGarbageCollector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,18 @@ public void Dispose()
m_disposed = true;

m_cts.Cancel();
m_timer.Dispose();

// Wait for an already-running timer callback to finish before returning. Timer.Dispose()
// alone does not wait for an in-flight callback, so a collection that started just before
// Dispose could still complete (and bump RunCount) afterwards. The WaitHandle overload
// signals once all callbacks have drained, guaranteeing no background collection runs
// after Dispose returns.
using (var timerCallbacksDrained = new ManualResetEvent(false))
{
if (m_timer.Dispose(timerCallbacksDrained))
timerCallbacksDrained.WaitOne();
}

m_cts.Dispose();
}

Expand Down
Loading