Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@rwf-rr
Copy link
Contributor

@rwf-rr rwf-rr commented Oct 15, 2025

RunActivity was slow to terminate. It took up to 10 seconds for the main menu form the re-appear after exiting the simulation.

RunActivity was waiting for the Host process to terminate. The Host process had a 10 second sleep, which delayed its termination.

This fix changes the sleep to 100 ms, and uses a counter to only execute the Host process function every 10 seconds.

PS: I am not sure what the Host process (it calls the Profiler) is meant to do.

twpol pushed a commit that referenced this pull request Oct 15, 2025
- Pull request #1082 at 8538170: Allow variable water level in glass gauge
- Pull request #1156 at f46d5f2: Fix incorrectly disabled options in train operations window
- Pull request #1091 at 492795a: Automatic speed control
- Pull request #1122 at b9b077b: Wagon Size and Centering Controls
- Pull request #1124 at e241a0d: Built-in PBL2 brake controller
- Pull request #1128 at d116396: Particle Emitter Overhaul
- Pull request #1157 at 39cd994: Dynamic brake authorization by TCS
- Pull request #1159 at 48c9a63: Skip OR warnings about TSRE-specific token Ruler
- Pull request #1163 at 2f9e292: Fix: Crash when using Camera 8 and F9.
- Pull request #1164 at 1ad9889: Fix: F9 crashes with a front coupled single steam locomotive by Csantucci.
- Pull request #1165 at aacd11b: docs: Add code guidelines for logging
- Pull request #1166 at 51e7f7a: Simplify loading of internal and game textures
- Pull request #1167 at 2c028a4: Fix: RunActivity slow to terminate because of long sleep in Host Process
twpol pushed a commit that referenced this pull request Oct 15, 2025
- Pull request #1082 at 8538170: Allow variable water level in glass gauge
- Pull request #1156 at f46d5f2: Fix incorrectly disabled options in train operations window
- Pull request #1091 at 492795a: Automatic speed control
- Pull request #1122 at a8f3ed2: Wagon Size and Centering Controls
- Pull request #1124 at e241a0d: Built-in PBL2 brake controller
- Pull request #1128 at d116396: Particle Emitter Overhaul
- Pull request #1157 at 39cd994: Dynamic brake authorization by TCS
- Pull request #1159 at 48c9a63: Skip OR warnings about TSRE-specific token Ruler
- Pull request #1163 at 2f9e292: Fix: Crash when using Camera 8 and F9.
- Pull request #1164 at 1ad9889: Fix: F9 crashes with a front coupled single steam locomotive by Csantucci.
- Pull request #1165 at aacd11b: docs: Add code guidelines for logging
- Pull request #1166 at 51e7f7a: Simplify loading of internal and game textures
- Pull request #1167 at 2c028a4: Fix: RunActivity slow to terminate because of long sleep in Host Process
twpol pushed a commit that referenced this pull request Oct 15, 2025
- Pull request #1082 at 8538170: Allow variable water level in glass gauge
- Pull request #1156 at f46d5f2: Fix incorrectly disabled options in train operations window
- 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 #1128 at d116396: Particle Emitter Overhaul
- Pull request #1157 at 39cd994: Dynamic brake authorization by TCS
- Pull request #1159 at 48c9a63: Skip OR warnings about TSRE-specific token Ruler
- Pull request #1163 at 2f9e292: Fix: Crash when using Camera 8 and F9.
- Pull request #1164 at 1ad9889: Fix: F9 crashes with a front coupled single steam locomotive by Csantucci.
- Pull request #1166 at 51e7f7a: Simplify loading of internal and game textures
- Pull request #1167 at 2c028a4: Fix: RunActivity slow to terminate because of long sleep in Host Process
@cjakeman
Copy link
Contributor

Hi Roger,

Thanks for picking this up.

PS: I am not sure what the Host process (it calls the Profiler) is meant to do.

I will raise this with James on Saturday and maybe he can shed some light on it. Then we could add a helpful comment explaining what's going on.

Chris

private const int SleepTime = 10000;
private const int DoHostTime = 10000;
private const int SleepTime = 100; // must be short enough for timely termination
private const uint DoHostIntervall = DoHostTime / SleepTime;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private const uint DoHostIntervall = DoHostTime / SleepTime;
private const uint DoHostInterval = DoHostTime / SleepTime;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Thanks for spotting this.

Copy link
Contributor

@cjakeman cjakeman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a spelling suggestion

twpol pushed a commit that referenced this pull request Oct 16, 2025
- Pull request #1082 at 8538170: Allow variable water level in glass gauge
- Pull request #1156 at f46d5f2: Fix incorrectly disabled options in train operations window
- 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 #1128 at d116396: Particle Emitter Overhaul
- Pull request #1157 at 39cd994: Dynamic brake authorization by TCS
- Pull request #1159 at 48c9a63: Skip OR warnings about TSRE-specific token Ruler
- Pull request #1163 at 2f9e292: Fix: Crash when using Camera 8 and F9.
- Pull request #1164 at 1ad9889: Fix: F9 crashes with a front coupled single steam locomotive by Csantucci.
- Pull request #1166 at 51e7f7a: Simplify loading of internal and game textures
- Pull request #1167 at 115325f: Fix: RunActivity slow to terminate because of long sleep in Host Process
twpol pushed a commit that referenced this pull request Oct 18, 2025
- Pull request #1082 at 8538170: Allow variable water level in glass gauge
- Pull request #1156 at f46d5f2: Fix incorrectly disabled options in train operations window
- 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 #1128 at d116396: Particle Emitter Overhaul
- Pull request #1157 at 39cd994: Dynamic brake authorization by TCS
- Pull request #1159 at 48c9a63: Skip OR warnings about TSRE-specific token Ruler
- Pull request #1163 at 2f9e292: Fix: Crash when using Camera 8 and F9.
- Pull request #1164 at 1ad9889: Fix: F9 crashes with a front coupled single steam locomotive by Csantucci.
- Pull request #1166 at 51e7f7a: Simplify loading of internal and game textures
- Pull request #1167 at 115325f: 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.
twpol pushed a commit that referenced this pull request Oct 19, 2025
- Pull request #1082 at 8538170: Allow variable water level in glass gauge
- Pull request #1156 at f46d5f2: Fix incorrectly disabled options in train operations window
- 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 #1128 at d116396: Particle Emitter Overhaul
- Pull request #1157 at 39cd994: Dynamic brake authorization by TCS
- Pull request #1159 at 48c9a63: Skip OR warnings about TSRE-specific token Ruler
- Pull request #1163 at 2f9e292: Fix: Crash when using Camera 8 and F9.
- Pull request #1164 at 1ad9889: Fix: F9 crashes with a front coupled single steam locomotive by Csantucci.
- Pull request #1166 at 51e7f7a: Simplify loading of internal and game textures
- Pull request #1167 at 115325f: 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 8c1d787: Better Handling of Wagons with Invalid Bogie Configuration
twpol pushed a commit that referenced this pull request Oct 19, 2025
- Pull request #1082 at 8538170: Allow variable water level in glass gauge
- Pull request #1156 at f46d5f2: Fix incorrectly disabled options in train operations window
- 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 #1128 at d116396: Particle Emitter Overhaul
- Pull request #1157 at 39cd994: Dynamic brake authorization by TCS
- Pull request #1163 at 2f9e292: Fix: Crash when using Camera 8 and F9.
- Pull request #1164 at 1ad9889: Fix: F9 crashes with a front coupled single steam locomotive by Csantucci.
- Pull request #1166 at 51e7f7a: Simplify loading of internal and game textures
- Pull request #1167 at 115325f: 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 8fe03b1: Better Handling of Wagons with Invalid Bogie Configuration
twpol pushed a commit that referenced this pull request Oct 19, 2025
- Pull request #1082 at 8538170: Allow variable water level in glass gauge
- Pull request #1156 at f46d5f2: Fix incorrectly disabled options in train operations window
- 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 #1128 at d116396: Particle Emitter Overhaul
- Pull request #1157 at 39cd994: Dynamic brake authorization by TCS
- Pull request #1163 at 2f9e292: Fix: Crash when using Camera 8 and F9.
- Pull request #1166 at 51e7f7a: Simplify loading of internal and game textures
- Pull request #1167 at 115325f: 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 8fe03b1: Better Handling of Wagons with Invalid Bogie Configuration
twpol pushed a commit that referenced this pull request Oct 21, 2025
- Pull request #1082 at 8538170: Allow variable water level in glass gauge
- Pull request #1156 at f46d5f2: Fix incorrectly disabled options in train operations window
- 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 #1128 at d116396: Particle Emitter Overhaul
- Pull request #1157 at 39cd994: Dynamic brake authorization by TCS
- Pull request #1166 at 51e7f7a: Simplify loading of internal and game textures
- Pull request #1167 at 115325f: 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 8fe03b1: 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
Copy link
Member

@twpol twpol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine, but I believe we would be better off making this work "properly" with an interruptible sleep, which means:

  • ProcessState class adds a new Sleep(int millisecondsTimeout) method
  • That method calls TerminateEvent.WaitOne(millisecondsTimeout)
  • Then HostProcess can call State.Sleep(SleepTime)

This would interrupt the wait when terminating, instead of the extra complexity of counting (not much I know)

twpol pushed a commit that referenced this pull request Oct 21, 2025
- Pull request #1082 at 8538170: Allow variable water level in glass gauge
- Pull request #1156 at f46d5f2: Fix incorrectly disabled options in train operations window
- 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 #1157 at 39cd994: Dynamic brake authorization by TCS
- Pull request #1167 at 115325f: 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 8fe03b1: 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
twpol pushed a commit that referenced this pull request Oct 22, 2025
- Pull request #1082 at 8538170: Allow variable water level in glass gauge
- Pull request #1156 at f46d5f2: Fix incorrectly disabled options in train operations window
- 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 #1157 at 39cd994: Dynamic brake authorization by TCS
- Pull request #1167 at 115325f: 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 a984e3f: 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
twpol pushed a commit that referenced this pull request Oct 22, 2025
- Pull request #1082 at 8538170: Allow variable water level in glass gauge
- Pull request #1156 at f46d5f2: Fix incorrectly disabled options in train operations window
- 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 #1157 at 39cd994: Dynamic brake authorization by TCS
- Pull request #1167 at 115325f: 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
twpol pushed a commit that referenced this pull request Oct 22, 2025
- Pull request #1082 at f1ade96: Allow variable water level in glass gauge
- Pull request #1156 at f46d5f2: Fix incorrectly disabled options in train operations window
- 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 #1157 at 39cd994: Dynamic brake authorization by TCS
- Pull request #1167 at 115325f: 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
twpol pushed a commit that referenced this pull request Oct 23, 2025
- Pull request #1082 at ebf0879: Allow variable water level in glass gauge
- Pull request #1156 at f46d5f2: Fix incorrectly disabled options in train operations window
- 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 #1157 at 39cd994: Dynamic brake authorization by TCS
- Pull request #1167 at 115325f: 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
twpol pushed a commit that referenced this pull request Oct 23, 2025
- 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 115325f: 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
Was suggested in PR review. Avoids the extra counter.
@rwf-rr
Copy link
Contributor Author

rwf-rr commented Oct 24, 2025

This is fine, but I believe we would be better off making this work "properly" with an interruptible sleep, which means:

Thanks for the suggestion. PR updated. @twpol Please re-review.

twpol pushed a commit that referenced this pull request Oct 24, 2025
- 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
twpol pushed a commit that referenced this pull request Oct 26, 2025
- Pull request #1082 at e4d7f70: 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 #1171 at 8fd2066: no internet connection is available, not possible to open the Menu Content Form
- Pull request #1169 at 6cf8c3e: Better Handling of Wagons with Invalid Bogie Configuration
twpol pushed a commit that referenced this pull request Oct 26, 2025
- Pull request #1082 at e4d7f70: 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 #1171 at 50efb5b: no internet connection is available, not possible to open the Menu Content Form
- Pull request #1169 at 6cf8c3e: Better Handling of Wagons with Invalid Bogie Configuration
twpol pushed a commit that referenced this pull request Oct 27, 2025
- Pull request #1082 at 45c4272: 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 #1171 at 50efb5b: no internet connection is available, not possible to open the Menu Content Form
- Pull request #1169 at 6cf8c3e: Better Handling of Wagons with Invalid Bogie Configuration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants