I'm learning Win 10 UWP and my goal is to write an SQLite database entry every 15 minutes using a background task.
My question is, what happens to the background task when the user shuts down the system and restarts it later on?
As I can understand, the user has to start the application again manually to register the background task again. Or is the background task somehow registered somewhere and restarts when the system is back up again without having to manually restart the background task again?
Once you've registered your background task, it stays around even after the computer reboots. The user doesn't have to launch your application again.
Related
I am writing a Windows 10 Mobile App (c#); it’s a notification/alarm app; I was wondering can I run a background service or task or scheduler which can trigger alarms or notifications. I am looking for something similar to windows services, so even when my phone restarts, that service or background task starts automatically and continuously run and show notifications to user. I have created windows 10 runtime (background task) but they stop when I restart my phone. How to automatically start a background task or windows mobile service. (It’s a windows 10 mobile app).
I have created windows 10 runtime (background task) but they stop when I restart my phone.
Since your background task is for triggering alarms or notifications, theoretically speaking, your background task should not be stopped when you restart your phone. Once the background task is registered, your background task should work until you unregister it or user turn off it, unless there are resource constraints which can force your background task stops.
Based on your description, you can try Periodic notification, this notification should also not be effected by restarting of your device.
How to automatically start a background task or windows mobile service. (It’s a windows 10 mobile app).
I don't know what cause your background task be stopped when your device is restarted, but most of the background tasks can automatically be started by system. By mobile service, I'm not clear what you referred to, if it is the app service like Azure, you can use Push notifications, if it is the local app service, I personally think this is not quite suitable for your scenario.
I've created a C# console application that does some updates in a SQL server database. I've set that application in the Task Scheduler to run daily. The application is running fine, but I noticed that the task never stops but keeps showing "Running", I have to click "End" by myself to stop it.
How can I let the task stop by itself without forcing it to stop ?
The task would stop by it self under normal conditions.
What purpose does your application server? It's doing something to keep it alive, since a normal console application would just run its course and shut down.
You always have the options of just straight up murdering it at the end of it's job, but it would be a better choice to identify what is keeping it alive.
System.Environment.Exit(0);
Is it multithreaded? Do you have some backgroundworkers running or anything?
This has been solved by using the files created in Debug instead of Release in the scheduled task, but i'm not sure why is that.
I have app with dispatcher timer. User set some interval(for example 30 sec) and press button start. App Each 30 sec play sound. All work ok. But when User lock phone timer stopped and nothing played. Can I play sound each 30 sec when phone is locked?
It is possible to keep the app running under lock screen.
Using Idle Detection, you can keep the app on, although screen is locked. Actually, it is not running in background, but in the foreground. Just the screen is locked. So, be careful not to drain user's battery.
You have to set the PhoneApplicationService.ApplicationIdleDetectionMode property to Disabled, for example in InitializePhoneApplication() method in App.xaml.cs:
PhoneApplicationService.Current.ApplicationIdleDetectionMode = IdleDetectionMode.Disabled;
Note that there are special certification requirements for this type of apps. Refer to section 6.3 (Apps running under a locked screen) of the following page:
Additional requirements for specific app types for Windows Phone
yes.
sure..
You can use the Scheduled Task Agent in windows phone.
using the Scheduled Task Agent, when you app is not running or stopped (not in background).
you can fire your Events.
For that you have to add the scheduled task agent into your project.
And in the ScheduledAgent.cs file find the OnInvoke method and put your code here.
this method performs the task in Background. (Means the code is executed when your phone is locked).
for more Reference click here Implement background agents for Windows Phone
I hope you get the destination. Now, just put that code into your application and its working.
I am building a Windows 8 Pro application and I would like the application to enter "Suspend" state immediately after losing focus (or being 'minimized')
This is for a kiosk application (won't actually be on the Store) where I want to relaunch/refocus the application when a user tries to hide it. So far, I can only 'refocus' it using a native C# app once the app has been killed (i.e. when the process does not exist in Process.GetProcessByName()). This is why I would like to kill the application-- the user should not be minimizing it so killing it is a cost the application can bear.
How can I get the application to terminate when it is minimized? I am wondering if it is possible to set the time-out period, or to intercept a general event in App.xaml.cs when the application itself has lost focus (then perhaps call App.Exit() terminate the process). I have tried the Application.Suspending event but takes too long to fire off. It takes about 10 seconds to fire off AFTER the application has been killed with ALT+F4.
I have a task scheduler which runs a C# console application every minute. It runs the .application file via a .bat file and does so successfully for a period of time before stopping completely.
Un-installing/re-installing my console application doesn't fix the problem and the task scheduler is showing the batch file as succesfully executing. Also, running the program manually works just fine.
My questions are:
How can I get this task to run again via the task scheduler. I have tried deleting and re-creating the task, uninstalling/reinstalling the applcation.
I have a scheduled backup task occuring around the time the application stops working. Volume shadow copy is not enabled. Could this be impacting my application and why?
In the task scheduler take a look at the Settings tab. You will find an option "If the task fails, restart every".
By default (this is not checked) then if your task fails it will not be run again. You can check your task history to see if it has failed. In any case it sounds like you want to be run again even if it failed the last time it ran.
This is the option you want to change.
Despite the help, I did not manage to isolate the cause of this problem.
I have re-developed my scheduler using Quartz.NET and it's now running as a Windows service.