Welcome Guest Search | Active Topics | Sign In | Register

unsure window.onbeforeunload is completed before stopping Options
Christian Porzio
Posted: Friday, March 17, 2017 6:40:35 PM
Rank: Advanced Member
Groups: Member

Joined: 10/4/2016
Posts: 104
Hi,

Some of our applications want to notify their backend that they are closing by implementing a web svc call in the window.onbeforeunload.

Somehow Chrome is able to guaranty the completion of that function before closing.

With EO.Web I did not find a clean way to do that. The only workaround I have so far is to Thread.Sleep(1750) before invoking EO.Base.Runtime.Shutdown()

Would you recommend a better approach? Note that not all web sites make this call, so I cannot really tie it up to the javascript function itself.

As always thank you many in advance for your inputs.

Regards
eo_support
Posted: Friday, March 17, 2017 8:22:33 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,072
Hi,

I am not aware of any way to guarantee a call to the server in window.onbeforeunload. All transport layer calls are done asynchronously, which means it always get queued up first. Thus there is always a chance they are abandoned before they can actually finish --- this behavior is done by design for performance reasons. For example, a user loads page A and then navigate to page B before everything in page A has finished loading, in that case the unfinished loading tasks in page A will be abandoned.

If you wish the backend to be reliably notified, you may want to look into web socket. That is designed to handle this kind of communications.

Thanks!

Christian Porzio
Posted: Tuesday, March 21, 2017 9:40:58 PM
Rank: Advanced Member
Groups: Member

Joined: 10/4/2016
Posts: 104
Actually I have resolved it by not calling any more from OnExit:
Code: C#
EO.Base.Runtime.Shutdown();


I was concerned that the processes spawn by the engine would not close but they do.

Is there any reason I should call
Code: C#
EO.Base.Runtime.Shutdown();


Regards
eo_support
Posted: Wednesday, March 22, 2017 8:56:01 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,072
Hi,

I am not sure if that will indeed resolve the issue for you.

As to calling EO.Base.Runtime.Shutdown, generally there is no need for you to call it. One scenario you may want to call this method is when you know your code is run in a separate AppDomain and you have no control over the life cycle of the AppDomain you are in such as in some plugins, in that case you can call Shutdown when your plugin is instructed to unload.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.