diff --git a/src/tests/Interop/COM/ComWrappers/Common.cs b/src/tests/Interop/COM/ComWrappers/Common.cs index 5d1994131e7a76438355e86c05345a48e2cfc6c7..4aa98b76e9031ce46cf525ef37188f0b276b9b42 100644 --- a/src/tests/Interop/COM/ComWrappers/Common.cs +++ b/src/tests/Interop/COM/ComWrappers/Common.cs @@ -21,9 +21,10 @@ class Test : ITest, ICustomQueryInterface { public static int InstanceCount = 0; + private int id; private int value = -1; - public Test() { InstanceCount++; } - ~Test() { InstanceCount--; } + public Test() { id = Interlocked.Increment(ref InstanceCount); } + ~Test() { Interlocked.Decrement(ref InstanceCount); id = -1; } public void SetValue(int i) => this.value = i; public int GetValue() => this.value;