private static void InitResourceHelper() { // Only the default AppDomain should have a ResourceHelper. All calls to // GetResourceString from any AppDomain delegate to GetResourceStringLocal // in the default AppDomain via the fcall GetResourceFromDefault. // Use Thread.BeginCriticalRegion to tell the CLR all managed // allocations within this block are appdomain-critical. // Use a CER to ensure we always exit this region. bool enteredRegion = false; bool tookLock = false; RuntimeHelpers.PrepareConstrainedRegions(); try { RuntimeHelpers.PrepareConstrainedRegions(); try { } finally { Thread.BeginCriticalRegion(); enteredRegion = true; Monitor.Enter(Environment.InternalSyncObject); tookLock = true; } if (m_resHelper == null) { ResourceHelper rh = new ResourceHelper(); System.Threading.Thread.MemoryBarrier(); m_resHelper = rh; } } finally { if (tookLock) { Monitor.Exit(Environment.InternalSyncObject); } if (enteredRegion) { Thread.EndCriticalRegion(); } } }
private static void InitResourceHelper() { bool flag = false; bool flag2 = false; RuntimeHelpers.PrepareConstrainedRegions(); try { RuntimeHelpers.PrepareConstrainedRegions(); try { } finally { Thread.BeginCriticalRegion(); flag = true; Monitor.Enter(InternalSyncObject); flag2 = true; } if (m_resHelper == null) { ResourceHelper helper = new ResourceHelper(); Thread.MemoryBarrier(); m_resHelper = helper; } } finally { if (flag2) { Monitor.Exit(InternalSyncObject); } if (flag) { Thread.EndCriticalRegion(); } } }