Resetting app data setting using background worker in wp7 - c#

I am building a WP7 app. I want to reset my app data settings at a given time. I have tried resetting by comparing the hour of the given time and "DateTime.Now.Hour" when the Main Page loads(i.e. when I open the app at the given time). But if I open the app after the given time, it doesn't reset at all. So, I want to know if there is any way to solve this. I haven't used Background Worker before but I think it can help. Can somebody suggest me a way out of it?.
Thanks in advance

You cannot run apps permanently in the background on Windows Phone. When your app launches or is activated you should check if the delete time has passed (DateTime.Now > deleteTime).
You could consider using a background agent that can run every 30 mins, but beware the limitations especially on 256MB devices.

Related

How do I run a process in a UWP before displaying app

I've completed a winform project that handles a uri scheme (TEL:)
I'm now trying to do the same in UWP. I've successfully got the app launching on TEL activation.
How do I stop the app showing when its run with arguments? Run silent.
The app runs a task and closes. There is no need for the UI unless the user hasn't done the first time set up or there is an error.
I've been looking into prelaunch but before painting myself into a corner I wanted to ask a more experienced user what the best practice is as I would like to publish this application and follow best practice.
I've checked similar questions but they were after a background service.
Thank you.
Answer thanks to Nico Zhu.
Can not launch an app without displaying UI but it is possible to use 'FullTrustProcessLauncher' to run an exe instead.
More information on this can be found here

Simple Application that executes every 15 minutes. How can I stop it from disturbing any Windows?

Basically, I have an application that runs every 15 minutes. I would like this Console application to remain hidden and not for example minimise/disturb full screen applications.
What would be the best way to accomplish this, it can't be a service though. I'm writing the console application in C#.
Thanks.
To run an application every 15 minutes use a scheduled task. The very simple way to avoid any window being shown is to make this a normal GUI app rather than a console app, but arrange that you do not show any windows in your GUI app.
like david said if you make it a gui program but never load any windows it will run in the background with nothing ever popping up or showing or anything.. another option would be to have your application run continuously and have it do something every 15 minutes...
One option would be to have the scheduled task run as a different user, Network Service maybe, depends on your needs. This will force it to run under the specificed users context and will not show up on other logged in users screens.
You don't need to do anything. A console application is invisible and doesn't interact with other windows. The only way to even know it's there is through Task Manager or something similar.

Alarm, even if application is shutdown

I have integrated a small to-do list in my WinForms application, where-in user can add tasks and set alarm for it. Is it possible to run timer (or alarm clock counter) in background, even if application is closed. I am using the AlarmClass written as answer here. The aim is only to show a MessageBox when the alarm time is reached and nothing else to do with the application. Also multiple alarm setting should be possible.
I am sorry if my question is not elaborated, coz I dont know wat other details I must include. But ready to reply your questions.
Thanks in advance.
Edit: Any comments on this link?
Short answer
No. If your application is shut down, there's no good way.
Long answer
Yes if you resort to clever hackery. You could:
Run your app in the system tray / background when the 'X' button is clicked
Run a scheduled task which launches your app in "alarm-checking" mode every N minutes
Write a windows service which launches your app for alarm events
I'm not sure, but can't you create a Windows application which only shows up in the Systemtray. Add the required keys to the registry to make sure it will automatically start when windows starts.
Otherwise you can split it up into two separate applications;
- Windows Application to manage the alert
- Windows Service to do the check in the background

Windows Forms GUI Stuck

lets say you are adding a feature to an old and running windows form application now the whole application is running in one thread and the application is really big and have many forms so you cant refract it to run in multithreads, now the application gui freeze everytime you make a process , is there is any way to have an indicator that its loading or in progress while its freezing ? without changing the whole design of the software to support threads etc ?
by the way i dont want it to stop freezing its ok to freeze i just want it to to indicate that its doing something !
any idea would be appreciated, thanks...
See BackGroundWorker componet if application is written using .net 2.0 or higher version.
You can set the form's Cursor property to Cursors.WaitCursor upon starting the long running action, and reset it to Cursors.Default upon finish. While your action executes you can call Application.DoEvents() but it may cause side effects if other events trigger in the mean time.

How should I run a background service for creating export files for a web site in the Windows world?

I've created a shiny new ASP.Net MVC site and I have offloaded the 'save as' type of functionality to a helper program that can be run in the background on the server so that the website doesn't need to take all that load.
I created it so that it's easy to run from the command line and right now I have it running from a windows scheduler. The problem is that that has a granularity of 1 minute, which means that some unlucky users of the website will click on the link and get a 59s wait + the time to actually process the report.
I'm also slightly worried about the start up cost of my program. I'm assuming that it would be cheaper to keep the program running constantly. I am worried about the program dying and not being respawned though. With the windows scheduler option at least I don't have to worry about my program bailing so much.
How have you dealt with that?
I'd create a Windows Service and have that running instead of an exe via windows scheduler. You can then set it to auto-start. Then you can just have a timer within the service to poll for work every x seconds.
Another alternative is to use something like MSMQ. Your front end would just insert a message into the queue to represent the work to do, then have a .NET service listening to the queue (you can get it to process messages immediately they appear in the queue, or check the queue manually yourself every x seconds).
Either way, I think a Windows Service is the way to go.

Categories