File tree Expand file tree Collapse file tree 2 files changed +10
-11
lines changed Expand file tree Collapse file tree 2 files changed +10
-11
lines changed Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments