How to create a new thread in WinJS (WinRT) - windows-runtime

Is it possible to create a new thread in WinJS? I have to continuously execute a while loop but I do not want it to tie up the UI.

You have two options:
WebWorker (as per joe). Getting data in & out of a web worker involves post/sendMessage. MSDN Details here.
If your operation is not javascript specific, You can create a thread in C#/C++, and use that to communicate back to the JavaScript world using WinRT events.

Related

Sharing session variables between Vaadin and embedded applications

I have a Vaadin v6 application that uses the embed component to show a JSP page from another application (JPivot, in this case). Both applications are running in the same application server (Tomcat). I need both applications to communicate and I'm trying to do this by using session attributes. However, each application has its own session and so one is ignorant of the other attributes. My question is how to make these applications communicate without using a database or an external file? It can be other solution than session attributes.
What you wish to do is either IPC between two web apps,
or sharing some informations between them.
If you have a cache available (memcached or similar) you could
store/retrieve the information there.
If no cache is available, then CrossContext=true might help you.
With this you can call "the other" webapp from inside the servlet/request.
Here is a simple explanation how this works
http://lukaszbudnik.blogspot.ch/2009/06/session-sharing-in-apache-tomcat.html
If you google for "tomcat session sharing" you will get many more results.
Please note that this CrossContext stuff only works as long as they are in the same tomcat instance.
As soon as you add another tomcat instance for load balancing or high availability this will break. In that case you should use some sort of message bus or message queue.

Create A background service in Windows phone 8 to update location

I have to create a Background Task which should run after every 1 minute and should call a Rest service to update the Mobile longitude and Latitude Location. The rest service for this purpose have been written all I have to do is to write a Task in my existing application which should perform this update. Can you guys please tell which is the most easiest way to implement this functionality.
Thanks,
There isn't a concept of a service like exists in Windows Desktop. Applications are running, or not on the phone. One application on the phone, tracking location, can be running in the background while other applications run.
If your application is in the foreground, you will just directly call the web services with updated location.
You can use a scheduled background agent to periodically update location, but it is likely that it won't update frequently enough for your needs.
MSDN has details about how to create an application that actively tracks location in the background, subject to some important limitations, and reasons the application may be deactivated:
The app stops actively tracking location. An app stops tracking location by removing event handlers for the PositionChanged and StatusChanged events of the Geolocator class or by calling the Stop() method of the GeoCoordinateWatcher class.
The app has run in the background for 4 hours without user interaction.
Battery Saver is active.
Device memory is low.
The user disables Location Services on the phone.
Another app begins running in the background.
In addition, there is a complete tutorial available for this scenario.

In Windows 8.1, does Consolidated mean Terminated?

There is a new API in the Windows 8.1 ApplicationView namespace. The ApplicationView.Consolidated | consolidated event. MSDN
Description: Occurs when the window is removed from the list of recently used apps or if the user executes a close gesture on it.
MSDN docs are a little vague. Is this an API developers can use to detect when their application has been terminated by the user or by the system? What is a scenario to handle this event?
The consolidated event is only fired by secondary views created through MSApp.createNewView, and thus does not apply to the main view of the app--that is, it's not fired when the main app window is closed. It's only there to let the app as a whole know that one of its secondary views has been closed.
It's demonstrated in the Multiple Views sample and there's some lengthy commentary in the code on the matter.
The short of it is that there isn't an event other than suspending that occurs when an app is closed. You use the suspending event to do whatever you need.

Realtime API for model synchronization

I am looking to extend an existing JavaScript/CoffeeScript application using the realtime API. What I want to do is synchronize a map used by the Model of my application, part of an MVC framework spinejs. This would require that all the operations of the API will be done on the Model of my application (which is pure client-side), and have no direct interaction with the View.
All the open-source examples of realtime-api I have found had the JS code within the HTML being displayed, or much of the operations for authorization/loading etc (quickstart,realtime-cube,realtime-playground).
Is it possible to use realtime-api, without having direct
interaction with the displayed content?
Furthermore, if any examples are available it would be greatly appreciated.
Once the auth is done, all the operations can be performed, without any user operation being necessary (i.e. they don't have to be triggered by a user event).
I can show you our RT code here, although it's non-trivial, the listeners are listening to our own model, which cause RT functions to be invoked.
In terms of the auth, it works fine, except if you want to support multiple accounts. For single accounts you can use the immediate mode to enable signing in without causing a popup.
If there are multiple accounts logged in, you will need a user event to start the auth without having a popup, immediate mode messes up multiple account handling. Note there is a bug in the multiple account selection screen anyway, which causes a poor user experience.

How can I pre-start my RAP application to trigger warmup right after startup

I have a RAP application which we deploy into a Tomcat instance. The application does some additional stuff during it's first startup.
Currently when the first user opens the webpage in a Browser, it takes quite a while until the application is ready because of this one-time initialization work.
This is bad for usability as the first user needs to wait a long time until this startup-work is done.
Is there a way to trigger or simulate a first session after the Tomcat is started so we can warmup the application and the first user receives feedback quickly?
I tried to do some simple URL-requests via URLConnection to simulate a browser, but it seems the protocol to trigger a new session is non-trivial.
I also tried to use HtmlUnit to request the page with JavaScript enabled, this works to some degree, but HtmlUnit is quite heavy for this simple step.
So is there an official API or at least some sort of workaround that allows me to pre-start and initialize the application?
Unless this initialization requires a UI session (i.e. a user), the configure method of your ApplicationConfiguration could be a suitable place. However, at this point, the ApplicationContext has not been completely set up, so it could be too early. Also, if your application is based on the workbench and extension points, you won't have an ApplicationConfiguration of your own.
Would you mind opening a bug report (http://eclipse.org/rap/bugs) and describe your use case? I think we should provide some kind of hook for applications to setup and clean up, e.g. an ApplicationContextListener?