Detect user selected option on Windows preventing restart C# - c#

So i have a program that runs in background and by accident i found that if you prompt restart and get the screen that some app prevents it if you click cancel my app actually dies. Is there a way to make app wait more or to check what user selected on that screen.
What i meant is this:
After this screen when i go cancel my app is dead.

Related

UWP Restart when closed by user

I have a uwp app that launches an external application (Notepad). I want to make it so that when the user closes the Notepad app by clicking the red x button in the top-right corner, Notepad restarts itself. Is this even possible and if so, how do I do it?
To restart the application on exit, you can take advantage of the confirmAppClose capability. When you capture the close event, you can launch the app and then finish closing the current instance. Keep in mind this is a restricted capability and will require special approval from Microsoft to submit to the Microsoft Store.

Windows Phone 8.1 Silverlight - Toast Notification Launch Causes App to Restart

I'm working on Toast Notifications for my WP8.1 Silverlight App that are activated via a background process. Whenever I tap on the Toast when it appears (or tap on it from the Notification Action Center), it always restarts the app. It navigates to the main page for a split-second and I notice that the Bing Map I have embedded in the Mainpage is blank, then it restarts. I specify in the toast for it to go to the mainpage as follows (with a parameter):
((XmlElement)toastNode).SetAttribute("launch", "#/MainPage.xaml?conversation=12345");
Other aberrant behavior is
When debugging, and the app is invoked from the Toast the main page 'onNavigatedTo' event gets hit twice both times with the parameter specified from the toast.
When the app relaunches itself after being invoked from the Toast, and I go back to the Start Screen and tap the Live Tile to be taken back to the app, it again needs to restart itself. This never happens if I launch the app normally from the Live Tile or Application Icon.
The debugger isn't catching anything. Could it be something to do with the app being tombstoned, or the app 'Applicated_Activated' event not being hit up properly?

WP8 timer app under lock screen

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.

Scheduled task user not logged in, how to change to interactive mode once user logs in

I have a scheduled task that runs an app; let's say notepad.exe. If the task "runs only when a user is logged in," I can see notepad, but if the task "runs whether user is logged in or not" notepad does not run in interactive mode. And even if I am logged in and run the task in this mode, I cannot see the notepad window or the process until I select "show all" in task manager. The problem is when notepad has an error, upon logging in, I cant see that error so there's no way of telling what the error is or what notepad was doing when it got the error. It looks like the task cant run in interactive mode since there is no logged in user at the time it starts. So my question is: is there a way to change notepad to interactive mode once a user does log in?
Looking at a programmatic solution, is there a way of using shell32 or user32 to change an application to interactive mode at run time?
Also, my issue is not with notepad obviously... just a proof of concept.
I don't know a lot about Scheduled Tasks, but if they behave like a service, then you will have a hard time getting into these windows. In a service when you enable a service to interact with the Desktop, if you want to see the windows that the service opens, then you need to give him a user account, and you'll only be able to see the windows if you're logged in into that account, and only when a new window is opened; when a new window is opened you get a notification in the Desktop (if my memory serves me well is in the top of the Desktop) that you have to click in order to see the opened application.
If you can modify the application of the scheduled task, then I recommend you to make it non gui and to report errors to either the Event Viewer or a log file. If you can't modify the application of the scheduled task, then you may try wrapping it as a service, so you get the notifications when a new window is opened.

How can I suspend my Windows 8 Pro app earlier than normal after being minimised?

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.

Categories

Resources