[HandleProcessCorruptedStateExceptions] //
#endif // FEATURE_CORRUPTING_EXCEPTIONS
internal static CompressedStackSwitcher SetCompressedStack(CompressedStack cs, CompressedStack prevCS)
{
CompressedStackSwitcher cssw = new CompressedStackSwitcher();
RuntimeHelpers.PrepareConstrainedRegions();
try
{
// Order is important in this block.
// Also, we dont want any THreadAborts happening when we try to set it
RuntimeHelpers.PrepareConstrainedRegions();
try
{
// Empty try block to ensure no ThreadAborts in the finally block
}
finally
{
// SetCompressedStackThread can throw - only if it suceeds we shd update the switcher and overrides
SetCompressedStackThread(cs);
cssw.prev_CS = prevCS;
cssw.curr_CS = cs;
cssw.prev_ADStack = SetAppDomainStack(cs);
}
}
catch
{
cssw.UndoNoThrow();
throw; // throw the original exception
}
return(cssw);
}