Skip to content

Commit 21d9ada

Browse files
authored
Merge pull request #1167 from rwf-rr/bugfix-runactivity-slow-exit
Fix: RunActivity slow to terminate because of long sleep in Host Process
2 parents 8951c4e + d5c0d64 commit 21d9ada

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
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: 2 additions & 2 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
//
@@ -93,7 +93,7 @@ void HostThread()
9393

9494
while (true)
9595
{
96-
Thread.Sleep(SleepTime);
96+
State.Sleep(SleepTime);
9797
if (State.Terminated)
9898
break;
9999
if (!DoHost())

0 commit comments

Comments
 (0)