Adding scoped CriticalSection