From f0f51bded09cbe247c47842f0a5ad98d42d42160 Mon Sep 17 00:00:00 2001 From: LaegotKit <100539902+LaegotKit@users.noreply.github.com> Date: Mon, 2 May 2022 11:12:02 -0400 Subject: [PATCH] Added removelist check Added removelist check to prevent locking the list when there is no work to be done. Fixes lag when script debug is active. --- Forms/FormMain.cs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Forms/FormMain.cs b/Forms/FormMain.cs index bed9671..6e43cb8 100644 --- a/Forms/FormMain.cs +++ b/Forms/FormMain.cs @@ -2747,18 +2747,21 @@ private void RemoveExitedScripts() finally { m_oScriptList.ReleaseReaderLock(); - if (m_oScriptList.AcquireWriterLock()) + if (removeList.Count > 0) { - try + if (m_oScriptList.AcquireWriterLock()) { - for (var i = removeList.Count - 1; i > -1; i--) + try { - m_oScriptList.RemoveAt(removeList[i]); + for (var i = removeList.Count - 1; i > -1; i--) + { + m_oScriptList.RemoveAt(removeList[i]); + } + } + finally + { + m_oScriptList.ReleaseWriterLock(); } - } - finally - { - m_oScriptList.ReleaseWriterLock(); } } }