What is a UI thread in windows phone 8? - multithreading

Hello i am new to developing application. now i am working on an app that have to track the location so it must work in the background when i do so it works will but when i get back to the app the UI is not updated
if (!App.RunningInBackground)
{
Dispatcher.BeginInvoke(() =>
{
one.Text = args.Position.Coordinate.Latitude.ToString();
two.Text = args.Position.Coordinate.Longitude.ToString();
});
}
and on the output
The thread 0x7b4 has exited with code 259 (0x103).
i do not know what is UI thread and i checked Google.

If you want to have an app that runs in background, you should use background agents.
For a good quick start this link is best.
Best practices and advices are found here.
And you want to run your app in background and want to update the textbox in foreground? what do you mean?
UI thread means the main thread in phone foreground app where all the activities take place. Any new async task has to be spawned from this UI thread only.
You have a code because your app has successfully exited the foreground.

Related

WKWebView load Function in which Thread

I am developing an App with an iOS Deployment target 15.6.
The App uses WKWebview for obtaining url information such as html. When I run a webView.load(url) function in the main thread it works but issues a warning "This method should not be called on the main thread as it may lead to UI unresponsiveness."
Although the function should not be used in a background thread I tried it but of course I got an error message "WKWebView.load(_:) must be used from main thread only".
How can I use the load function correctly so that I receive no warnings?

Prevent stopping of Node app while Windows 10 desktop switches to lock screen

I'm implementing a Node application using Electron that communicates with a websocket server. The app runs smoothly as long as the user is logged in. If the user is inactive for some time, the lock screen of the Windows 10 system shows up. The websocket connection then seems to be stopped as long as the user unlocks the desktop.
Is there any chance to have the websocket connection open and running also if the client is in lock screen?
Maybe there is a solution for not letting the System lock the screen through node?
found solution by myself:
electron offers powerSaveBlocker class
example:
const { powerSaveBlocker } = require('electron')
const id = powerSaveBlocker.start('prevent-display-sleep')
console.log(powerSaveBlocker.isStarted(id))
powerSaveBlocker.stop(id)
More details can be found at the official api documentation:
https://electronjs.org/docs/api/power-save-blocker

Spawn process that keeps running after app.quit()

How can I launch a user-defined application from an electron application. After the application is launched the electron application should quit, and restart after the program has finished. This to free system resources.
I was hoping to be able to use a child_process.spawn with detach option and unref.
let command= 'notepad.exe && ./electron.exe'
const launched_application = child_process.spawn(command,[],{detached:true,stdio:'ignore',shell:true})
launched_application.unref()
app.quit()
When the code hits app.close() the child_process is also killed. Is there a way to keep the child_process running after app.quit()
This also gives an arror on the && part, which I'm planning to fix using a .bat file. Any recommendations regarding this are also welcome.
if you want to relaunch app again then you should just close or hide all windows and activate setInterval to keep checking if child process is alive or not with help of pid ...
after that you can create new window again or show hidden window... and if you want fresh process then you should relaunch app after you get callback of user quitting that child application....

Coded UI in VS2013 closes the application automatically once test method is completed running

In visual studio 2013, coded ui closes the application automatically once all test method completed running.
[TestInitialize]
public void TestInitialize()
{
uiCommonEE = UICommonEE.GetCommonEE();
}
[TestCleanup]
public void TestCleanup()
{
}
[TestMethod]
public void OpenWorkspaceTest()
{
uiCommonEE.SetBaseState();
uiCommonEE.OpenWorkspace("C:\Path\EE_Multmodule_AllDataTypes.eew");
}
I'm launching my application from TestInitialize() Method
once the testmethod is completed running, application gets closed automatically.
In testcleanuup() and classcleanup() method I haven't written anything.
I want application to be still running once all the test method of the codedUI are completed running.
Thanks in advance
You can use CloseOnPlayback on the ApplicationUnderTest or BrowserWindow class, but this will only keep the application open during the test run. The moment all test methods in the test class have been executed the playback engine will still cleanup any instance created during the test. So between all test methods in the test class the application will be kept open, when all tests completed everything will be cleaned up.
Run the application from the [ClassInitialize] or the [AssemblyInitialize] methods, but do not use Coded UI's methods to start it. This is because Coded UI keeps track of started applications so it can close them at the end of the test run. Instead use one of the other Windows process start methods, the ProcessStartInfo and Process classes, see here, may be suitable.
The question does not say what should happen if the tests are started when the application is already running. So perhaps the [ClassInitialize] or the [AssemblyInitialize] method should check whether the application is already active before running it, or perhaps the application should ignore or reject attempts to start it when it is already running.

win 8 app multi threading

I have an win8 app and I want to add proggress ring while app gets info from server.
but when
proggressRing.isActivate = true;
checkServer();
the app freezes until returns from checkServer() and proggressRing does not activates when it freezes.
I asked around and said you have to use multi threading
how can I use multi thread in c# or is there any other way?
thanks
There are multiple solutions to this
1) first ensure that CheckServer is implemented as Async Task (Async Event based can still be used).
2) If it is CPU intensive operation, use Task.Run to queue the Task to run on a threadpool thread.
have a look at this post
http://msdn.microsoft.com/en-us/library/windows/apps/hh452713.aspx and this one
http://msdn.microsoft.com/en-us/library/vstudio/hh191443.aspx

Resources