Is there any way to prevent console application to close?

后端 未结 2 1166
小鲜肉
小鲜肉 2021-01-27 17:49

Is there any way to prevent console application to close ?

(that the user can\'t close the program)

2条回答
  •  被撕碎了的回忆
    2021-01-27 18:49

    Normally a console application can be aborted by pressing CTRL-C.

    You can prevent CTRL-C from aborting your application by setting the Console.TreatControlCAsInput property or handling the Console.CancelKeyPress event.

    Of course this won't stop the user from being able to kill your process, e.g. using Task Manager.

提交回复
热议问题