mirror of
https://github.com/PCSX2/pcsx2.git
synced 2025-12-16 04:08:48 +00:00
GSDumpGUI: Replaced watchdog thread with Forms.Timer
Explicit dispose of watchers and timer on Form dispose, also event enum.
This commit is contained in:
parent
77f52cf04d
commit
c0a38b45f1
@ -48,7 +48,6 @@ namespace GSDumpGUI
|
|||||||
|
|
||||||
static private TreeNode CurrentNode;
|
static private TreeNode CurrentNode;
|
||||||
static public IntPtr hMainIcon;
|
static public IntPtr hMainIcon;
|
||||||
static public bool isProgRunning;
|
|
||||||
|
|
||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main(String[] args)
|
static void Main(String[] args)
|
||||||
@ -118,14 +117,15 @@ namespace GSDumpGUI
|
|||||||
Server.OnClientAfterConnect += new TCPLibrary.Core.Server.ConnectedHandler(Server_OnClientAfterConnect);
|
Server.OnClientAfterConnect += new TCPLibrary.Core.Server.ConnectedHandler(Server_OnClientAfterConnect);
|
||||||
Server.OnClientAfterDisconnected += new TCPLibrary.Core.Server.DisconnectedHandler(Server_OnClientAfterDisconnected);
|
Server.OnClientAfterDisconnected += new TCPLibrary.Core.Server.DisconnectedHandler(Server_OnClientAfterDisconnected);
|
||||||
Server.Enabled = true;
|
Server.Enabled = true;
|
||||||
isProgRunning = true;
|
|
||||||
|
|
||||||
Application.EnableVisualStyles();
|
Application.EnableVisualStyles();
|
||||||
Application.SetCompatibleTextRenderingDefault(false);
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
frmMain = new GSDumpGUI();
|
|
||||||
Application.Run(frmMain);
|
|
||||||
|
|
||||||
isProgRunning = false;
|
using (frmMain = new GSDumpGUI())
|
||||||
|
{
|
||||||
|
Application.Run(frmMain);
|
||||||
|
}
|
||||||
|
|
||||||
Server.Enabled = false;
|
Server.Enabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
7
tools/GSDumpGUI/Forms/frmMain.Designer.cs
generated
7
tools/GSDumpGUI/Forms/frmMain.Designer.cs
generated
@ -13,9 +13,12 @@
|
|||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (disposing && (components != null))
|
if (disposing)
|
||||||
{
|
{
|
||||||
components.Dispose();
|
DisposeExtra();
|
||||||
|
|
||||||
|
if (components != null)
|
||||||
|
components.Dispose();
|
||||||
}
|
}
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,13 +22,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.Threading;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -97,7 +95,9 @@ namespace GSDumpGUI
|
|||||||
private List<FileSystemWatcher> _dllWatcher;
|
private List<FileSystemWatcher> _dllWatcher;
|
||||||
private List<FileSystemWatcher> _dumpWatcher;
|
private List<FileSystemWatcher> _dumpWatcher;
|
||||||
|
|
||||||
private ConcurrentQueue<int> _watcherEvents;
|
enum FileChangeEvt { Dll = 1, Dump = 2 };
|
||||||
|
private ConcurrentQueue<FileChangeEvt> _watcherEvents;
|
||||||
|
private System.Windows.Forms.Timer _fileChangesWatchdog;
|
||||||
|
|
||||||
private string _gsdxPathOld, _dumpPathOld;
|
private string _gsdxPathOld, _dumpPathOld;
|
||||||
|
|
||||||
@ -136,41 +136,59 @@ namespace GSDumpGUI
|
|||||||
|
|
||||||
_dllWatcher = new List<FileSystemWatcher>();
|
_dllWatcher = new List<FileSystemWatcher>();
|
||||||
_dumpWatcher = new List<FileSystemWatcher>();
|
_dumpWatcher = new List<FileSystemWatcher>();
|
||||||
_watcherEvents = new ConcurrentQueue<int>();
|
_watcherEvents = new ConcurrentQueue<FileChangeEvt>();
|
||||||
|
|
||||||
Thread watcherThread = new Thread(ChangesWatchdogThread);
|
_fileChangesWatchdog = new System.Windows.Forms.Timer();
|
||||||
watcherThread.Start();
|
_fileChangesWatchdog.Tick += new EventHandler(FileChangesWatchdog);
|
||||||
|
_fileChangesWatchdog.Interval = 1000;
|
||||||
|
_fileChangesWatchdog.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ChangesWatchdogThread()
|
private void DisposeExtra()
|
||||||
{
|
{
|
||||||
while (Program.isProgRunning)
|
foreach (FileSystemWatcher w in _dllWatcher)
|
||||||
{
|
{
|
||||||
bool dllReload = false;
|
w.EnableRaisingEvents = false;
|
||||||
bool dumpReload = false;
|
w.Dispose();
|
||||||
|
|
||||||
int evt;
|
|
||||||
while (_watcherEvents.TryDequeue(out evt))
|
|
||||||
{
|
|
||||||
if (evt == 1) dllReload = true;
|
|
||||||
else if (evt == 2) dumpReload = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dllReload) this.Invoke((MethodInvoker)delegate { ReloadGsdxDlls(); });
|
|
||||||
if (dumpReload) this.Invoke((MethodInvoker)delegate { ReloadGsdxDumps(); });
|
|
||||||
|
|
||||||
Thread.Sleep(1000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (FileSystemWatcher w in _dumpWatcher)
|
||||||
|
{
|
||||||
|
w.EnableRaisingEvents = false;
|
||||||
|
w.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
_dllWatcher.Clear();
|
||||||
|
_dumpWatcher.Clear();
|
||||||
|
|
||||||
|
_fileChangesWatchdog.Stop();
|
||||||
|
_fileChangesWatchdog.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FileChangesWatchdog(object source, EventArgs e)
|
||||||
|
{
|
||||||
|
bool dllReload = false;
|
||||||
|
bool dumpReload = false;
|
||||||
|
|
||||||
|
FileChangeEvt evt;
|
||||||
|
while (_watcherEvents.TryDequeue(out evt))
|
||||||
|
{
|
||||||
|
if (evt == FileChangeEvt.Dll) dllReload = true;
|
||||||
|
else if (evt == FileChangeEvt.Dump) dumpReload = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dllReload) ReloadGsdxDlls();
|
||||||
|
if (dumpReload) ReloadGsdxDumps();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnDllDirChange(object source, FileSystemEventArgs e)
|
private void OnDllDirChange(object source, FileSystemEventArgs e)
|
||||||
{
|
{
|
||||||
_watcherEvents.Enqueue(1);
|
_watcherEvents.Enqueue(FileChangeEvt.Dll);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnDumpDirChange(object source, FileSystemEventArgs e)
|
private void OnDumpDirChange(object source, FileSystemEventArgs e)
|
||||||
{
|
{
|
||||||
_watcherEvents.Enqueue(2);
|
_watcherEvents.Enqueue(FileChangeEvt.Dump);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void BindListControl<TModel, TElement>(ListControl lb, TModel model, Func<TModel, BindingList<TElement>> collectionAccessor, Expression<Func<TElement, string>> displayTextAccessor, Expression<Func<TModel, int>> selectedIndexAccessor)
|
private static void BindListControl<TModel, TElement>(ListControl lb, TModel model, Func<TModel, BindingList<TElement>> collectionAccessor, Expression<Func<TElement, string>> displayTextAccessor, Expression<Func<TModel, int>> selectedIndexAccessor)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user