I have an application that connects to an API. The API needs a logout function to be called when work is finished so that its system works properly. I have a function that connects to this API, does some work, and then logs out and it works correctly. The problem is when the program crashes, or I need to close it during work. I have added a call to the logout function in the FormClosing event in my MDI parent form. Will this work for all cases of closing the program?
To be more specific - I know, that clicking on the red X button will trigger this event. But will closing the program from the Windows' Task Manager also trigger it? And will stopping the program from Visual Studio (during development, when it was also run from Visual Studio) also trigger it?