improve:进程保护

This commit is contained in:
2026-02-18 22:04:46 +08:00
parent 681b674eb2
commit 3d601189f1
@@ -64,13 +64,11 @@ namespace Ink_Canvas.Helpers
return; return;
} }
if (Interlocked.Exchange(ref _writeGate, 1) == 1) var waitStart = Environment.TickCount;
while (Interlocked.CompareExchange(ref _writeGate, 1, 0) != 0)
{ {
var start = Environment.TickCount; if (Environment.TickCount - waitStart < 2000) Thread.Sleep(10);
while (Interlocked.CompareExchange(ref _writeGate, 1, 1) == 1 && Environment.TickCount - start < 2000) else Thread.Sleep(50);
{
Thread.Sleep(10);
}
} }
var normalized = NormalizePath(targetPath); var normalized = NormalizePath(targetPath);