未验证 提交 ada0d61b 编写于 作者: A Aaron Robinson 提交者: GitHub

Fix race in ComWrappers test (#51153)

Since the finalizer thread runs async with the test, we need to
atomically decrement the static instance counter.
上级 927b1c54
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册