Window.Destroy: Await async cleanup #16510
Replies: 1 comment
-
change regardless
worry not, anything in async void WILL complete, but windows will close before it's completed, if you don't want this behavior, you can try replacing async void with async Task, if that doesn't work which is possible because everything is, you might consider executing this via other method like instead of via window.Destroying maybe execute your function first then call .Dispose on window Rest assure there are many ways to make sure you execute the function before the window is destroyed you just have to test the behavior of the system you are using and be creative, for example if |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I would await to await async cleanup operation, these async opperations are requests made to API controllers on the server.
So in my app I lock records on the database when performing updates so that no one else can modify and I would like to release on app close.
Also I want to log the user out by making another HTTP request.
In the normal flow, the user would click the 'Logout' button, but the user might click the 'X' close button on Windows or swipe close on Android.
This is the code I have, but I think the Window is destoying itself to quickly for the async opperations to finish:
Do you understand what I am trying to do?
Is this the correct place to have the code?
Thanks,
Luke
Beta Was this translation helpful? Give feedback.
All reactions