0

I have a Winforms app and usually when a user runs an app the UI of the app visible only, but if you set in settings open as Console app, as a result, each time when the app will be opened the terminal will be opened as well (BTW I need this option to be enabled in my case).

enter image description here

Problem is that I have a logic in Closing form event and it works well if a user closes the app by clicking on the cross at the top of the app window, but if they close the app by click cross on the terminal window the app doesn't get any closing events. It just terminates the app process.

So, the question is - is there a way to catch the closing event if the user tries to close the app through the closing terminal instead of closing the app?

Sirop4ik
  • 4,543
  • 2
  • 54
  • 121
  • Check [this](https://stackoverflow.com/questions/474679/capture-console-exit-c-sharp) and [this](https://stackoverflow.com/q/11291352/14171304) out. – dr.null Feb 09 '21 at 12:01
  • Different Console app Close events handled here: [Adding MenuItems to Contextmenu for a TrayIcon in a Console app](https://stackoverflow.com/a/65048753/7444103), including a Close request coming from the ContextMenu of a custom NotifyIcon Window. – Jimi Feb 09 '21 at 13:49

0 Answers0