|
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
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
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!
|
|
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
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
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!
|
|