Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 5579d0e

Browse files
jbe2277stephentoub
authored andcommitted
Add missing finalizer back to BackgroundWorker
The type isn't sealed, it exists in .NET Core purely for backwards compatibility with existing code, and in the desktop implementation it has a finalizer. If an existing component had derived from BackgroundWorker and overridden Dispose to enable finalization of unmanaged resources, in .NET Core they would not be cleaned up. Putting back the missing finalizer.
1 parent ae73c4f commit 5579d0e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/System.ComponentModel.EventBasedAsync/src/System/ComponentModel/BackgroundWorker.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ public BackgroundWorker()
2424
_progressReporter = new SendOrPostCallback(ProgressReporter);
2525
}
2626

27+
~BackgroundWorker() // exists for backwards compatibility
28+
{
29+
Dispose(false);
30+
}
31+
2732
private void AsyncOperationCompleted(object arg)
2833
{
2934
_isRunning = false;

0 commit comments

Comments
 (0)