4 ms·
If the problem with the second work-around (the reason it's not satisfactory) is that it's not supported as part of the platform, forcing you to use a "trick" t
by ptx 3y ago
If the problem with the second work-around (the reason it's not satisfactory) is that it's not supported as part of the platform, forcing you to use a "trick" to "outsmart the compiler", then C# has this solved: System.GC.KeepAlive [1] is an official part of the .NET platform and documented to do exactly this, so presumably Microsoft would not break it when making changes to the GC.
[1] https://learn.microsoft.com/en-us/dotnet/api/system.gc.keepalive?view=net-8.0 https://learn.microsoft.com/en-us/dotnet/api/system.gc.keepa...