Skip to content
This repository has been archived by the owner on Sep 1, 2021. It is now read-only.

Commit

Permalink
Fix sync instance check (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
KedamaOvO committed Nov 30, 2018
1 parent 8fb8105 commit 0af24be
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions Sync/Tools/StartupHelper.cs
Expand Up @@ -51,7 +51,7 @@ private void SyncInstanceLocker(MemoryMappedFile syncMappedFile, bool forceExit)
{
CurrentIO.WriteColor(DefaultI18n.LANG_Instance_Exist, ConsoleColor.Red);
int limit = 50, current = 0;
while (oldSync.WaitForExit(100))
while (!oldSync.WaitForExit(100))
{
current++;
if (current > limit) break;
Expand All @@ -73,14 +73,6 @@ private void SyncInstanceLocker(MemoryMappedFile syncMappedFile, bool forceExit)
}
}
}
private void PerLuanchChecker(bool forceStart)
{
//Check sync.exe is run
using (var syncMappedFile = MemoryMappedFile.CreateOrOpen(SYNC_GUID, 4))
{
SyncInstanceLocker(syncMappedFile, forceStart);
}
}

static void InitSync()
{
Expand Down Expand Up @@ -122,15 +114,19 @@ internal StartupHelper(string[] args)

internal void Start()
{
PerLuanchChecker(ForceStart);
//Check sync.exe is run
using (var syncMappedFile = MemoryMappedFile.CreateOrOpen(SYNC_GUID, 4))
{
SyncInstanceLocker(syncMappedFile, ForceStart);

InitSync();
CurrentIO.WriteWelcome();
InitSync();
CurrentIO.WriteWelcome();

while (true)
{
var cmd = CurrentIO.ReadCommand();
SyncHost.Instance.Commands.invokeCmdString(cmd);
while (true)
{
var cmd = CurrentIO.ReadCommand();
SyncHost.Instance.Commands.invokeCmdString(cmd);
}
}
}
}
Expand Down

0 comments on commit 0af24be

Please sign in to comment.