Micro-optimizations in .NET (x86/x64)
Part 2
Search for a command to run...
Articles tagged with #csharp
Part 2
Part 1
In .NET, an array of a simple integral type can be cast to an array of another integral type, provided they have the same element size. This is possible because the CLR treats these arrays as having a compatible memory layout. int[] arrayOfInts = new...
This example demonstrates how to execute native x86 machine code directly from .NET and, conversely, how to call a managed .NET method from that native code — all without loading any external libraries. How it works The core idea is to allocate a chu...
Be careful with explicit struct layout. Even when executing purely managed code, it is possible to trigger an AccessViolationException. Before I encountered this case, I was under the impression that the CLR (Common Language Runtime) prevented such m...
It is no secret that thread synchronization mechanisms in multithreaded applications consume a lot of resources. In .NET, starting with version 3.5, some synchronization primitives were introduced that take into account the fact that calls to Windows...