OSDN Git Service

TimelineScheduler内で使用するTimerが適切に破棄されない不具合を修正
authorKimura Youichi <kim.upsilon@bucyou.net>
Fri, 4 Feb 2022 15:27:01 +0000 (00:27 +0900)
committerKimura Youichi <kim.upsilon@bucyou.net>
Fri, 4 Feb 2022 15:27:35 +0000 (00:27 +0900)
Fixes: c8b60400 ("タイムラインの定期更新に使用するタイマーの間隔を動的に制御する")

OpenTween/TimelineScheduler.cs
OpenTween/Tween.cs

index 51ebfd7..d25da19 100644 (file)
@@ -29,7 +29,7 @@ using System.Threading.Tasks;
 
 namespace OpenTween
 {
-    public class TimelineScheduler
+    public class TimelineScheduler : IDisposable
     {
         private readonly AsyncTimer timer;
 
@@ -37,6 +37,8 @@ namespace OpenTween
         private bool systemResumeMode = false;
         private bool preventTimerUpdate = false;
 
+        public bool IsDisposed { get; private set; } = false;
+
         public bool Enabled
         {
             get => this.enabled;
@@ -360,5 +362,22 @@ namespace OpenTween
 
             return delay > TimeSpan.Zero ? delay : TimeSpan.Zero;
         }
+
+        protected virtual void Dispose(bool disposing)
+        {
+            if (this.IsDisposed)
+                return;
+
+            if (disposing)
+                this.timer.Dispose();
+
+            this.IsDisposed = true;
+        }
+
+        public void Dispose()
+        {
+            this.Dispose(disposing: true);
+            GC.SuppressFinalize(this);
+        }
     }
 }
index 52ad95c..23ecd0c 100644 (file)
@@ -496,6 +496,7 @@ namespace OpenTween
                 //sf.Dispose();
                 sfTab.Dispose();
 
+                this.timelineScheduler.Dispose();
                 this.workerCts.Cancel();
 
                 if (IconCache != null)