From 771a0e7b6b1276087515bbe94de28358cb92963b Mon Sep 17 00:00:00 2001
From: alielie <alielie@git.com>
Date: 星期四, 04 六月 2026 10:32:27 +0800
Subject: [PATCH] 优化老化;

---
 Plugin.TsSupport/TeststandWrapper.cs |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/Plugin.TsSupport/TeststandWrapper.cs b/Plugin.TsSupport/TeststandWrapper.cs
index b3c7f07..ea15087 100644
--- a/Plugin.TsSupport/TeststandWrapper.cs
+++ b/Plugin.TsSupport/TeststandWrapper.cs
@@ -1,7 +1,7 @@
 锘縰sing NationalInstruments.TestStand.Interop.API;
 using NationalInstruments.TestStand.Interop.UI.Ax;
 using System;
-using System.Diagnostics;
+using System.Runtime.InteropServices;
 
 namespace Plugin.TsSupport
 {
@@ -213,11 +213,19 @@
 
         public bool ReleaseSeqFile()
         {
-            if (testSeq != null)
+            if (this.testSeq != null && this.engine?.ReleaseSequenceFileEx(this.testSeq, 4) == true)
             {
-                return engine?.ReleaseSequenceFileEx(testSeq, 4) == true;
+                Marshal.ReleaseComObject(this.testSeq);
+                this.testSeq = null;
             }
-            return true;
+
+            if (this.modeSeq != null && this.engine?.ReleaseSequenceFileEx(this.modeSeq, 4) == true)
+            {
+                Marshal.ReleaseComObject(this.modeSeq);
+                this.modeSeq = null;
+            }
+            this.engine?.UnloadAllModules();
+            return this.testSeq == null && this.modeSeq == null;
         }
 
         public void SetContext(object context)

--
Gitblit v1.9.1