Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ AddRef()

Definition at line 7 of file DeferredDisposableLifetime.cs.

8 {
9 int num;
10 int value;
11 do
12 {
13 num = Volatile.Read(ref _count);
14 if (num < 0)
15 {
16 throw new ObjectDisposedException(typeof(T).ToString());
17 }
18 value = checked(num + 1);
19 }
20 while (Interlocked.CompareExchange(ref _count, value, num) != num);
21 return true;
22 }

References System.Threading.DeferredDisposableLifetime< T >._count, System.Threading.Interlocked.CompareExchange(), System.Threading.Volatile.Read(), System.ToString, and System.value.