I have a problem that occurs during shutdown. I have a piece of code written in C ++ that is wrapped in a DLL and added to other applications. This does a ton of things, including starting another application (sever) written in C #.
However, after starting shutdown, C ++ code starts the C # application because it was killed at shutdown, which crashes quickly due to a system crash.
Then the error window stops shutting down until the user can handle it, which is annoying. Is there a way to ask the OS: "Hey, do you close / restart / exit?" So I do not start the application while this is happening? I guess a solution at both ends will be fine.
== EDIT ==
A bit more clarification. Code that runs as an embedded .dll cannot assume that the application in which it is attached has any "window". In addition, I would like something that I could request, and not an event that I should listen to, because I can skip this event because of time. I am wondering if there is any function that would effectively give me something like this
bool IsSystemShutting();
And in this regard, the C # option will work for me as well as in C ++. But in the .NET framework, SystemEvents.SessionEnding and SystemEvents.SessionEnded are both events and properties. It very often happens that I will subscribe to this event AFTER the event has occurred, so I am not well.
source share