Avoid potential race conditions on the Dispose() method

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9444 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2006-10-12 23:10:18 +00:00
commit ea6f44edd2
4 changed files with 35 additions and 19 deletions

View file

@ -1071,12 +1071,14 @@ public class Base : IDisposable {
}
public virtual void Dispose() {
if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) {
swigCMemOwn = false;
examplePINVOKE.delete_Base(swigCPtr);
lock(this) {
if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) {
swigCMemOwn = false;
examplePINVOKE.delete_Base(swigCPtr);
}
swigCPtr = new HandleRef(null, IntPtr.Zero);
GC.SuppressFinalize(this);
}
swigCPtr = new HandleRef(null, IntPtr.Zero);
GC.SuppressFinalize(this);
}
public virtual uint UIntMethod(uint x) {