diff --git a/projects/clr/rocclr/runtime/device/pal/palvirtual.cpp b/projects/clr/rocclr/runtime/device/pal/palvirtual.cpp index 383c96c42e..112db3df76 100644 --- a/projects/clr/rocclr/runtime/device/pal/palvirtual.cpp +++ b/projects/clr/rocclr/runtime/device/pal/palvirtual.cpp @@ -2716,9 +2716,12 @@ bool VirtualGPU::waitAllEngines(CommandBatch* cb) { } void VirtualGPU::waitEventLock(CommandBatch* cb) { - // Make sure VirtualGPU has an exclusive access to the resources - amd::ScopedLock lock(execution()); - bool earlyDone = waitAllEngines(cb); + bool earlyDone = false; + { + // Make sure VirtualGPU has an exclusive access to the resources + amd::ScopedLock lock(execution()); + earlyDone = waitAllEngines(cb); + } // Free resource cache if we have too many entries //! \note we do it here, when all engines are idle,