1 internal static unsafe IntPtr InterlockedExchangePointer(IntPtr lpAddress, IntPtr lpValue) 2 { 3 IntPtr ptr2; 4 IntPtr ptr = *((IntPtr*)lpAddress.ToPointer()); 5 do 6 { 7 ptr2 = ptr; 9 ptr = Interlocked.CompareExchange(ref ptr, lpValue, ptr2); 10 } 11 while (ptr != ptr2); 12 return ptr; 13 }
用到了 unsafe thank you~
没有必要使用指针,在c#中