If my application crashes, I use ExceptionFilter to catch the crash, perform some final actions, and then show the user a message box saying that the application crashed.
Since the application has already crashed, I cannot (or I dared) do this, because if I do too much, the executable can access the damaged memory and crash again. Some of the things that I cannot do right now (or I dare not do) are to close network connections, Oracle database sessions, ...
The problem is that if the application crashes and the user goes out for lunch while the MessageBox is open, other users may be blocked due to an open database session. Therefore I want:
- Or a MessageBox with a timeout. The problem is that you cannot do this with the standard MessageBox Win32 API function, and I do not want to make a specific dialog for it (because I want to minimize the logic that is executed after the failure).
- Or the ability to close a MessageBox from another thread (another thread may provide timeout logic).
I missed something in the Win32 API and is it possible to have a MessageBox with a timeout?
Or how to properly close an open MessageBox from another thread (how to get a MessageBox handle, how to close it, ...)?
source share