Skip to content

Commit 0b79811

Browse files
committed
Fixed graceful exit stopping client from starting again
1 parent b468646 commit 0b79811

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

src/ReolinkRestart/ReolinkClient/IReolinkClientService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ public interface IReolinkClientService
44
{
55
void Start();
66

7-
void Terminate();
7+
void Terminate(bool waitForExit = false);
88

99
bool IsClientRunning();
1010

src/ReolinkRestart/ReolinkClient/ReolinkClientService.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,16 @@ public void Start()
2626
}
2727
}
2828

29-
public void Terminate()
29+
public void Terminate(bool waitForExit = false)
3030
{
3131
var process = GetClientProcess();
32+
3233
process?.CloseMainWindow();
34+
35+
if (waitForExit)
36+
{
37+
process?.WaitForExit();
38+
}
3339
}
3440

3541
public bool IsClientRunning()

src/ReolinkRestart/ReolinkRestartService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public void Start()
3636
private void RestartTimer_Elapsed(object? sender, ElapsedEventArgs e)
3737
{
3838
SetNextRestartAtUtc();
39-
reolinkClientService.Terminate();
39+
reolinkClientService.Terminate(true);
4040
reolinkClientService.Start();
4141
}
4242

0 commit comments

Comments
 (0)