I need to use Interlocked Operations (CompareExchange, Increment etc.) against memory in MemoryMappedFile
s in .NET.
I found this answer to a very similar question. The problem is that Interlocked Operations are not exported from kernel32 (or any other) dll on 64 bit OS (see e.g. http://blog.kalmbachnet.de/?postid=46).
Is there any other way how I can call Interlocked functions on a block of memory in a 64bit .NET process?
Write yourself a small C++/CLI helper library that provides interlocked operations consumable by managed code.
I believe the fastest interop path would be to expose a managed class that internally calls into an unmanaged function which itself makes use on the interlocked intrinsics. That way you don't even have to go through PInvoke.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With