Windows Phone 7 Scheduled tasks running - c#

As i understand i can launch a PeriodicTask from my windows phone application. But will it be called after application is terminated? Or, most important, will it be called by system after device reboot (before user run the main app next time)?

Yeah, they will run after a reboot and when your application is terminated but Battery Save Mode can prevent execution.
Good introduction:
http://blogs.infosupport.com/blogs/alexb/archive/2011/05/26/multi-tasking-in-windows-phone-7-1.aspx

Related

Windows system tray application not running from windows service and task schedular

I have a windows service to create a process which will run a windows desktop GUI application, but service cannot run an application with UI.
I then moved to task schedular to run my windows UI application but unfortunately the exe starts in background and there is no UI in foreground. I can see a process running in task manager in both the case, task schedular and windows service.
Is there a way i want to run a windows desktop system tray application to run as soon as the machine starts.
Thanks!
you can try to put the application in the run registry for example.
if i am not mistaking the task scheduler is preventing interactive system tray items.
See this article for more info about this option

In UWP app (Windows 10), how can I prevent Windows OS from entering Sleep mode?

I am developing UWP app (Windows 10) that record user voice through microphone. I need to prevent OS going in to sleep mode while the recording is in progress.
I already used below code to prevent screen lock.
var displayRequest = new Windows.System.Display.DisplayRequest();
displayRequest.RequestActive();
But it only works on mobile phone, tables. Desktop PC stills going on sleep mode.
Make sure the DisplayRequest object has a global scope. If you only define it within the function then it goes out of scope and gets released and the computer will go to sleep.
Hold on to the global object for as long as you need, and then call RequestRelease() on it when your done.
While recording is in progress, your app should also be in the foreground otherwise it will be considered inactive and screen will be locked even after executing displayRequest.RequestActive();.
An app is considered to be inactive (not running in the foreground) when:
Tablet mode: If your app is not focused then it is considered inactive
Desktop mode: If your app is minimized then it is considered inactive
For more details on this topic you can refer this blog post by windows app team.

C# - Windows Forms - Windows Sleep

I have an application build on Visual Studio 2013 with C# and Windows Forms.
This application runs on system tray and every 15 minutes (using a System.Windows.Forms.Timer component) visits a REST website, gets JSON data from it and displays them on the application.
The application is in Beta (i have it installed in a few clients for testing) and i was informed that very rarely, after computer recovers from sleep mode it will throw an exception (you can continue using it pressing the continue in the popup window as i was informed).
I have never seen this error in any of my development rigs (Windows 7 64bit, Windows 8.1 and then updated to Windows 10). The two clients that informed me about this exception were running Windows 7 32bit and 64bit.
I have seen this but what should i do when Mode is changed? Should i stop the Timer and then restart it when the Mode changes back to PowerModes.Resume?
As per the answer to this SO Post, Timer checks if any event has missed and fires accordingly. So the exception might be related to getting data from the REST website.
Maybe the exception occurs because your network card is turned off by the OS to save power. Try getting some details of the exception.

Determine if Windows Store App has been suspended or tombstoned from Windows Service

I have an application switcher in Windows 8.1 which enumerates all top level windows (EnumWindows in user32). Unfortunately this call will include suspended and tombstoned Windows Store Applications. I can detect when a process is suspended by checking if all threads are suspended and waitreason is also suspended. I can however not see any difference between if they have been suspended or tombstoned and I would, like ALT-TAB, show the suspended apps but not the tombstoned ones. I have also tried to see any differences between these processes in Process Explorer without success.
TLDR;
Is there any way that I could, from a Windows Service or Desktop application, query a process to see if it is tombstoned (and not just suspended)?
When a Windows Store app is terminated because the system needs to free resources--which is what I assume you mean by tombstoned--then it's process is removed entirely (that is, they disappear from Task Manager).
To differentiate between apps that are suspended and those that have been "closed" using Alt+F4, the close button, or the swipe-down gesture, call IsWindowVisible on the handle you get back from EnumWindows. If it's false, then the app has been tombstoned; if it's still true, then the app is just suspended.

Launch program under interactive logon user from .NET WinService

At the moment we have .NET WinService started under LocalService user at windows start. The service launch another WinForms Application using Process.Start().
But there are several problems in this solution:
We don't wait for an interactive user logon and the Application falls because it tries and fails to initialize DirectX device.
Application launched under LocalService perfectly interacts with user desktop in Windows XP. But it doesn't work in Windows 7 because of there are different graphic stations for each user in win7.
Sometimes we need to run application with current interactive logon user rights.
Does anybody know how to wait for user interactive logon in the service and start WinForms Application with these user rights?
I think this helps to solve all problems.
You will need a separate client app. Check out this document, page 6: http://msdn.microsoft.com/en-us/windows/hardware/gg463353.aspx.
For your monitoring/restart scenario look at CreateProcessAsUser as mentioned in the document. You will almost certainly need to have your client app coordinate with the service for this, and it's still pushing a square peg into a round hole.
I would try using a combination of the answers above.
To solve #1
At user logon, launch the Winforms application using autostart in registry or startup folder. Make it notify the service that it was started successfully.
To make sure that the Winform app is started successfully after user log on:
Have your service that checks if application is started running in the background as you have now but don't let it do the initial startup.
Instead just let it register when user logs on, should be possible to do by listening to OnSessionChange.
Set a delay for X number of seconds to allow the login/startup process finish before it starts checking for a running application (ok maybe not the best solution).
If the service discovers that the application is not started or crashes, restart it from the service using the method Mark points out, CreateProcessAsUser.
Is it possible that this just isn't the right approach for what you're trying to do? It seems possible that you'd be better off putting the monitoring logic or whatever has the uptime requirements into the service so that it's "always on" so to speak. Then you would be left with UI logic in the WinForms app, which could be open or closed with no ill effect.

Categories