-
-
Notifications
You must be signed in to change notification settings - Fork 986
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent premature end of the Benchmark process at Ctrl-C, fixes #2483 #2661
Conversation
I don't think it's desirable for ctrl-c to abort only a single benchmark. I use it frequently to abort a benchmark run altogether. |
4a7a38b
to
f73549c
Compare
…otnet#2483 * PowerManagementApplier and ConsoleTitler system state is now reverted at Process termination. * To prevent code duplication, DisposeAtProcessTermination class is introduced.
f73549c
to
c545c08
Compare
Tim, I first tried to implement a kind of 'ConsoleControl' that ensures the process is not terminated (by setting ConsoleCancelEventArgs.Cancel to While browsing BDN's source code for what to do, I discovered that some other classes already reverted system state at process termination. Then I choose to follow that pattern for both the power settings and the console title. |
I like your solution. One thing that I wonder is whether |
2917b7c
to
cd7b6a4
Compare
I added some xml documentation to explain the design and reason not to implement full disposable pattern. Please read 1. Constrained Execution Regions and related classes as A finalizer is only needed when a class maintains native resources (e.g. a handle). Footnotes |
cd7b6a4
to
64c2f4f
Compare
While not technically native resources, I would argue that system state falls in that category. Anyway, I'm not saying it needs to be done, I was just curious if it should. Since you also hooked it up to the process exit event, the cases where a finalizer would be used are probably covered. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @leonvandermeer!
Set ConsoleCancelEventArgs.Cancel to true so that Benchmark process continues and PowerPlan is reverted at end of aborted Benchmark.
Note that at Ctrl-C (or Ctrl-Break) press, current benchmark fails (as all its processes are killed). The main run loop continues running remaining benchmarks.
As it would (imho) require some complicated code to set
stop
to true at Ctrl-C press, I decided to document current behavior.(If you do like to have all benchmarks aborted at Ctrl-C press, let me know and I'll implement such behavior)