“Ctrl + C” buttons pressed handle C# console app

不羁的心 提交于 2020-01-12 22:30:43

问题


How can I handle two buttons pressed simultaneously ('Ctrl' + 'C'), not in the WindowsForms application, but in console C# application?


回答1:


I suspect you want to set Console.TreatCtrlCAsInput to true. (Assuming you don't want this to terminate the app.)




回答2:


Check out Console.TreatControlCAsInput property;

Gets or sets a value indicating whether the combination of the Control modifier key and C console key (Ctrl+C) is treated as ordinary input or as an interruption that is handled by the operating system.



来源:https://stackoverflow.com/questions/14939217/ctrl-c-buttons-pressed-handle-c-sharp-console-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!