How do I wait, till Application.Navigate finishes in Wisej Hybrid?

0
0

We want to use Application.Navigate on our Local Webserver to switch to our Remote Webserver. After the Remote Webserver finishes its task, it will call Application.Navigate to return control back to the Local Webserver.

However, the issue we are facing is that Application.Navigate from the Local Webserver does not wait for the Remote Webserver to navigate back. If we attempt to wait for the onclose callback by putting the current thread to sleep, the application freezes completely, and the previously called Application.Navigate does not get executed.

  • You must to post comments
0
0

Hello Levie,

I’ve attached a sample project to this Link. I could not use the upload from this Forum because of the Limit 3,9 MB.

In the sample, I’ve implemented the behavior I mentioned in the OnClick method of LocalWebserver.Page1.

In the Program.cs file of RemoteWebserver, I’ve registered the corresponding endpoint where the request is handled. However, as I mentioned earlier, Application.Navigate does not wait until RemoteWebserver navigates back to the local webserver. As a result, when I try to read the response from that request, I receive an empty response because the request has not yet been executed.

If you’d like to test it yourself, you can set the URL of the RemoteWebserver in Shared.Navigation.Funktionen.Navigation.cs.

I hope you get what we are trying to accomplish with this architecture and can help us.

Best regards,
Konstantin

  • Levie (ITG)
    Hi Konstantin, thanks for the sample. if the local app (local web server) just needs to fetch data (or run a remote task) on the remote web server it might make sense to use HttpClient and GetAsync() instead of Application.Navigate(). We should have some examples around showing how to set up REST endpoints on the remote web server if you’re interested?
  • Konstantin Janzen
    Hello Levie, we looked into using a HttpClient, but then we would have to implement our endpoints as ASP.NET endpoints. That would mean, we can’t use the Wisej.Hybrid Methods to e.g. retrieve files from the device or access our own logic via the IClientHandlers. Best regards Konstantin
  • You must to post comments
0
0

Hey Konstantin,

There is no popup window in a Hybrid app – only application redirects. So the onclose handler will not work. There shouldn’t be any reason to put the current thread to sleep while waiting.

You might want to look at the Application.ApplicationRefresh event handler to manage a redirect.

If you attach a small runnable sample we can try to provide more help!

Best regards,
Levie

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.