Skip to content

Commit 2c028a4

Browse files
committed
Reduce sleep to respond to terminate more quickly.
1 parent e57a7a1 commit 2c028a4

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

Source/RunActivity/Viewer3D/Processes/HostProcess.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// COPYRIGHT 2022 by the Open Rails project.
1+
// COPYRIGHT 2022 by the Open Rails project.
22
//
33
// This file is part of Open Rails.
44
//
@@ -62,7 +62,9 @@ public class HostProcess
6262
readonly Game Game;
6363
readonly Thread Thread;
6464

65-
private const int SleepTime = 10000;
65+
private const int DoHostTime = 10000;
66+
private const int SleepTime = 100; // must be short enough for timely termination
67+
private const uint DoHostIntervall = DoHostTime / SleepTime;
6668

6769
public HostProcess(Game game)
6870
{
@@ -91,13 +93,18 @@ void HostThread()
9193
GlobalMemoryStatusEx(memoryStatus);
9294
CPUMemoryVirtualLimit = Math.Min(memoryStatus.TotalVirtual, memoryStatus.TotalPhysical);
9395

96+
uint sleepCount = 0;
9497
while (true)
9598
{
9699
Thread.Sleep(SleepTime);
97100
if (State.Terminated)
98101
break;
99-
if (!DoHost())
100-
return;
102+
if (sleepCount % DoHostIntervall == 0)
103+
{
104+
if (!DoHost())
105+
return;
106+
}
107+
sleepCount++;
101108
}
102109
}
103110

0 commit comments

Comments
 (0)