when my application in tombstoning I need to wait until WebClient UploadStringAsync will return response before being tombstoned. I Was trying to achieve it by blocking UI thread for few seconds, but i noticed, that when UI is blocked, no response is coming. When i’m releasing the lock (no matther that is Thread.sleep or ManualResetEvent) , response is comming in this same moment.
Of course, UploadStringAsync and UploadStringCompleted working on Threads other that UI.
Maybe You will knows what is the reason of these behavior?
when my application in tombstoning I need to wait until WebClient UploadStringAsync will return
Share
You can’t and shouldn’t do this:
You can’t block indefinitely when the app is being deactivated because the OS won’t let you and you may have to update indefinitely as there is no way to tell how long the web request will take, or even possible.
Instead, you should submit data to your web server at an appropriate time (or times) during the normal usage of the app. If you want to save particualr state during deactivation you should persist this (as approrpiate) and then send it when the application is reactivated or re-launched (again as appropriate depending on the type and relevancy of the data).