I have created a Windows Application using C# (.NET Framework v4.0). The application purpose is a variety of Third Party Application API Integration into a single one.
Currently, I am facing an issue where the client starts the API requests. Due to some reason like Internet slowness the API Response takes a bit longer. The Client closes the application using the Red Application Exit Button or in some rare cases uses Task Manger to exit the application.
Issue now persists like, the API Request is processes succesfully in their side but before the response has been read in our side the Application has been closed and looses the thread and does not reflect in our side.
Is there any method through which we can control this application Exit ? Can we block this application exit especially when the API Reqest is in process.
Solution Under Implementation
- Use a Global Variable when the application API Request is in progress.
- Use the MDI Form OnClosing event trigger to check the status of the variable and block the Application Exit.
This method will not block, Task Manager application exit.
Is there any possible method which can be implemented to block this issue or a better method which can substantially reduce this specific error from my application.
Aucun commentaire:
Enregistrer un commentaire