The context switch is a very low core activity, so it is unlikely (I don't know for sure) that such hooks exist.
You definitely will not be able to do this with code that runs in normal .Net runtime, at least because it does not allow full control over threads and does not start in kernel mode.
Now, if the question is: βCan I write kernel code in C #β, than - yes * (* - I do not believe that there is an available compiler for C # that will generate its own code that can be executed at the kernel level - write your own).
source share