mirror of
https://github.com/mirror/processhacker
synced 2026-06-08 16:03:24 +00:00
fixed BaseObject bugs
git-svn-id: svn://svn.code.sf.net/p/processhacker/code@1521 21ef857c-d57f-4fe0-8362-d861dc6d29cd
This commit is contained in:
@@ -144,7 +144,7 @@ namespace ProcessHacker.Common.Objects
|
||||
|
||||
// Don't need to finalize the object if it doesn't need to be disposed.
|
||||
if (!_owned)
|
||||
GC.SuppressFinalize(this);
|
||||
this.DisableFinalizer();
|
||||
|
||||
Interlocked.Increment(ref _createdCount);
|
||||
#if DEBUG
|
||||
@@ -161,8 +161,7 @@ namespace ProcessHacker.Common.Objects
|
||||
// Get rid of GC ownership if still present.
|
||||
this.Dispose(false);
|
||||
// Zero the weak reference count.
|
||||
this.Dereference(_weakRefCount, false);
|
||||
_weakRefCount = 0;
|
||||
this.ClearWeakReferences();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -287,6 +286,15 @@ namespace ProcessHacker.Common.Objects
|
||||
get { return Thread.VolatileRead(ref _weakRefCount); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all weak references.
|
||||
/// </summary>
|
||||
private void ClearWeakReferences()
|
||||
{
|
||||
this.Dereference(_weakRefCount, false);
|
||||
_weakRefCount = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disables the finalizer if it is not already disabled.
|
||||
/// </summary>
|
||||
@@ -473,6 +481,7 @@ namespace ProcessHacker.Common.Objects
|
||||
return 0;
|
||||
|
||||
Thread.BeginCriticalRegion();
|
||||
_refMutex.Acquire();
|
||||
|
||||
try
|
||||
{
|
||||
@@ -482,6 +491,7 @@ namespace ProcessHacker.Common.Objects
|
||||
}
|
||||
finally
|
||||
{
|
||||
_refMutex.Release();
|
||||
Thread.EndCriticalRegion();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user