Запретить окну консоли убить процесс ⇐ C#
Запретить окну консоли убить процесс
I am adding the debugging functionality to Small Visual Basic language (written with VB .NET), which I built on top of MS Small Basic (Written with C#). I have two issues:
Issue 1: The SB/sVB TextWindow represents the Console window, and it works fine when it is accessed from a separate process (like running the exe files compiled by the language), but it has troubles in the debug mode. The TextWindow (Console) doesn't work in debug mode. It is inactive and user can't write into it. The code uses win32 APIs to show the console, then uses the System.Console class method to interact with it. In WinForms and WPF project, this will interact with Output Window not the console window. This is the exception I get when I try to read a key: System.InvalidOperationException: 'Cannot read keys when either application does not have a console or when console input has been redirected from a file.
Edit: I found a solution for this issue: I discovered that the console window doesn't work when I run the sVB project in VS .NET in debugging mode, but if I run it without debugging, or launch the sVB.EXE outside VS .NET, the console window works, and this is fine with me. So, issue 1 is already solved, but issue 2 still needs a solution.
Issue 2: The console window terminates the whole process when it is closed, and I can't find a way to prevent that. I've read similar topics here, but I couldn't find a proper solution. For example, disabling the close button is not a full solution, because user can still press Ctrl+C. I also tried using the SetConsoleCtrlHandler to and intercept the close event, but I couldn't cancel terminating the process. Note that closing the process while running in the debugging mode closes sVB itself! This is also an issue when running any app.exe as closing the console while other windows are open will close them all!
Is there any solution for these issues? And if not, can I use a normal window for the TextWindow, and if so how to make the code execution wait for the return of the Read methods until the user submits his input in such a window? Thanks.
Источник: https://stackoverflow.com/questions/780 ... he-process
I am adding the debugging functionality to Small Visual Basic language (written with VB .NET), which I built on top of MS Small Basic (Written with C#). I have two issues:
Issue 1: The SB/sVB TextWindow represents the Console window, and it works fine when it is accessed from a separate process (like running the exe files compiled by the language), but it has troubles in the debug mode. The TextWindow (Console) doesn't work in debug mode. It is inactive and user can't write into it. The code uses win32 APIs to show the console, then uses the System.Console class method to interact with it. In WinForms and WPF project, this will interact with Output Window not the console window. This is the exception I get when I try to read a key: System.InvalidOperationException: 'Cannot read keys when either application does not have a console or when console input has been redirected from a file.
Edit: I found a solution for this issue: I discovered that the console window doesn't work when I run the sVB project in VS .NET in debugging mode, but if I run it without debugging, or launch the sVB.EXE outside VS .NET, the console window works, and this is fine with me. So, issue 1 is already solved, but issue 2 still needs a solution.
Issue 2: The console window terminates the whole process when it is closed, and I can't find a way to prevent that. I've read similar topics here, but I couldn't find a proper solution. For example, disabling the close button is not a full solution, because user can still press Ctrl+C. I also tried using the SetConsoleCtrlHandler to and intercept the close event, but I couldn't cancel terminating the process. Note that closing the process while running in the debugging mode closes sVB itself! This is also an issue when running any app.exe as closing the console while other windows are open will close them all!
Is there any solution for these issues? And if not, can I use a normal window for the TextWindow, and if so how to make the code execution wait for the return of the Read methods until the user submits his input in such a window? Thanks.
Источник: https://stackoverflow.com/questions/780 ... he-process
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Python Fintech Import заставляет macOS (Sequoia) убить процесс (Exc_BAD_ACCESS)
Anonymous » » в форуме Python - 0 Ответы
- 23 Просмотры
-
Последнее сообщение Anonymous
-