Calling a method before quitting the application?

0 votes

Is there a way to succesfully implement this functionality:

void OnApplicationQuit()
{

storageService.UpdateDocumentByKeyValue(dbName,collectionName,key,value,

jsonDoc, new UnityCallBack());

}

 

I want to update a document before quitting an application. If the application is closed before the callback occurs there is no change on the server.

Is there a way to call a method in a way that there would be change on the server no matter if callback function is called or not?

How should I resolve this issue? Thank you for your help.

asked Mar 18, 2015 in App42 Cloud API-BaaS by kraner (43 points)

1 Answer

0 votes
When application is quit, onApplicationQuit calling is done to make cleaning and wrap up of app data. You are calling async method from inside this method, in this case OS will stop/suspend your app as soon as OnApplicationQuit method is completed. To make sure that updateDoc method execution completes  without any interrupt, you have to wait in onApplicationQuit until updateDoc method returns.
 
Let me know if it makes sense.
answered Mar 19, 2015 by ajay123 (899 points)
Thank you for your answer. The problem is that I cannot wait in onApplicationQuit function unitl updateDoc method returns, because the application on web player quits. So there is no way that updateDoc would be successfull if I do not wait for the callback?
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...