File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
Source/RunActivity/Viewer3D/Processes Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments