I'm trying to stop C# from collecting garbage for some time.
I found that I can do this using the GC.TryStartNoGCRegion()
method.
However, this throws this exception:
Unhandled Exception: System.NotImplementedException: The method or operation is not implemented. at System.GC.StartNoGCRegionWorker (System.Int64 totalSize, System.Boolean hasLohSize, System.Int64 lohSize, System.Boolean disallowFullBlockingGC) [0x00000] in <1400ea11d6fd49d4939be686a9549fb4>:0 at System.GC.TryStartNoGCRegion (System.Int64 totalSize, System.Boolean disallowFullBlockingGC) [0x00000] in <1400ea11d6fd49d4939be686a9549fb4>:0 ...
I executed this line of code:
GC.TryStartNoGCRegion(4096, true)