Skip to content

Commit cf1239e

Browse files
committed
Automatic merge of T1.6-145-g7915033ac and 11 pull requests
- Pull request #1082 at ebf0879: Allow variable water level in glass gauge - Pull request #570 at 1b6b22e: glTF 2.0 support with PBR lighting - Pull request #1091 at 492795a: Automatic speed control - Pull request #1122 at 73c47b4: Wagon Size and Centering Controls - Pull request #1124 at e241a0d: Built-in PBL2 brake controller - Pull request #1130 at 0f4342d: Fix F9 points to an incorrect car ID. - Pull request #1157 at 39cd994: Dynamic brake authorization by TCS - Pull request #1167 at d5c0d64: Fix: RunActivity slow to terminate because of long sleep in Host Process - Pull request #1168 at 6e2942f: Fix exception when exiting with MapForm or SoundDebugForm open. - Pull request #1169 at 6cf8c3e: Better Handling of Wagons with Invalid Bogie Configuration - Pull request #1171 at 8fd2066: no internet connection is available, not possible to open the Menu Content Form
13 parents 853d507 + 7915033 + ebf0879 + 1b6b22e + 492795a + 73c47b4 + e241a0d + 0f4342d + 39cd994 + d5c0d64 + 6e2942f + 6cf8c3e + 8fd2066 commit cf1239e

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

Source/RunActivity/Processes/ProcessState.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,5 +95,11 @@ public void WaitTillFinished()
9595
DebugFileStream.Write("{0},WTF-\n", DateTime.Now.Ticks);
9696
#endif
9797
}
98+
99+
/// <summary>Wait for the specified number of milliseconds, unless termination is signalled.</summary>
100+
public void Sleep(int milliseconds)
101+
{
102+
TerminateEvent.WaitOne(milliseconds);
103+
}
98104
}
99105
}

Source/RunActivity/Viewer3D/Processes/HostProcess.cs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ public class HostProcess
6262
readonly Game Game;
6363
readonly Thread Thread;
6464

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

6967
public HostProcess(Game game)
7068
{
@@ -93,18 +91,13 @@ void HostThread()
9391
GlobalMemoryStatusEx(memoryStatus);
9492
CPUMemoryVirtualLimit = Math.Min(memoryStatus.TotalVirtual, memoryStatus.TotalPhysical);
9593

96-
uint sleepCount = 0;
9794
while (true)
9895
{
99-
Thread.Sleep(SleepTime);
96+
State.Sleep(SleepTime);
10097
if (State.Terminated)
10198
break;
102-
if (sleepCount % DoHostInterval == 0)
103-
{
104-
if (!DoHost())
105-
return;
106-
}
107-
sleepCount++;
99+
if (!DoHost())
100+
return;
108101
}
109102
}
110103

0 commit comments

Comments
 (0)