Can an app written with .net Compact Framework restart itself?
What are some of the common patterns to achieve this? I would like to have a self-updating application that restarts itself if update was done.
Of course, I could have 2 .exe: one that updates and the actual app, but I would rather just have one.
Absolutely. It's actually way easier to do than on the desktop. If you're using the SDF, use this:
var thisName = Assembly.GetExecutingAssembly().GetName().CodeBase;
var time = DateTime.Now.AddSeconds(11);
Notify.RunAppAtTime(thisName, time);
If you want to do it manually, you'd p/invoke CeRunAppAtTime.
Note that you must have a launch time of > 10 (not >= 10) seconds in the future or the "launch will happen immediately (an artifact of how the default notification setup is set in the kernel).
Related
I'm trying to get acquainted with test automation using Microsoft TFS Api.
I've created the program which runs my test set - it uses code similar to one described here, e.g.:
var testRun = _testPoint.Plan.CreateTestRun(false);
testRun.DateStarted = DateTime.Now;
// ...
testRun.Save();
I believe this forces them to start as soon as any of agents can run them, instead of being delayed to certain time. Am I wrong? Anyway, it works all right.
But I was told by my lead that the task should be started each time the new input files are copied to certain folder (on the network I think, or perhaps in TFS).
So I'm searching for a way which allow to trigger tests on some condition - but currently without any luck. Probably I miss proper keywords.
I only found something vaguely related here but it seems they say it is not possible in a proper way.
So are there any facilities in TFS / MTM, any ways or approaches to achieve my goal? Thanks in advance for any hints / links.
You would need to write a system service (or other) that uses the file system watcher. Then when the file changes you can run your code above.
There is no built in feature in TFS to watch a folder for changes.
I wanna create a notification system on my website?(something like stack-overflow)
How can we schedule a task for mailing the notification for users on each 24 hours?
Can we use MVC4 or we should use windows service ?
Edit:
My Experience with using FluentScheduler in 3 month within a MVC4 App .
FluentScheduler is easy to config and using but it doesn't run tasks any time. Sometimes run and sometimes doesn't run.
I think the best way for scheduling is Windows Service to ensure running a task at the specific time.
Found this to be an awesome scheduler, FluentScheduler
Usage:
// Schedule an ITask to run at an interval
Schedule<MyTask>().ToRunNow().AndEvery(2).Seconds();
You need a .Net Job Scheduler. Here is a good one: http://quartznet.sourceforge.net/
You can use ATrigger scheduling service. A .Net library is also available to create scheduled tasks without overhead. Errors log, Analytics, Tasks Listings and more benefits.
Disclaimer: I was among the ATrigger team. It's a freeware and I have not any commercial purpose.
maybe you wanna use a scheduled task. Doing this in a MVC is a bad idea (mixing responsabilities) and building a windows service looks like an overkill to me (because is something doesn't need to run all the time).
I use scheduled task of windows.
I have build a little app than enter a record in the bd, then access the website with this recordId(Guid) as a parameter.
In mvc i check if the id exist, if it exist i run tasks then delete the record in the db, if not i ignore it.
this way im able to add schedule with a param. without updating the app each time i need a new scheduled task. i just add a new task like
"myapp.exe /MyNewTaskName"
hope this help someone ;-)
First of all;
Add Nuget package Install-Package FluentScheduler
Add your registry class that inherit Registry and some code
// Schedule a simple task to run at a specific time
Schedule(() => System.Diagnostics.Debug.Write("This is from service " + DateTime.Now.Second+"\n"))
.ToRunNow().AndEvery(2).Seconds();
Register that registry class in Application_Start of Global.asax.cs
with TaskManager
TaskManager.Initialize(new Test());
GitHub
There is also a built-in option, QueueBackgroundWorkItem. It was added in .Net 4.5.2 and here is a guide on how to use it in MVC.
In addition to previously mentioned FluentScheduler you also have HangFire. And if you plan on deploying to Azure there's a handful of different services for this.
I have a Windows forms application which I have a bit of a sporadic issue with. The application would randomly start/spawn another instance of itself without any warning or reason. I only have one use of Process.Start in the whole application (15 forms/files and about 5000 lines of code) and that calls a net use command to map a network drive.
I've not been able to reproduce this in my testing and therefore I made the project a Windows Assembly Framework single instance application (pros/cons of this I know). This has obviously stopped any other instances of the application from running, but now at random intervals their program will minimise and snap to another application they have running. I don't know for certain whether this is related but they certainly sound a bit close for comfort!
Any ideas/pointers/thoughts appreciated.
Thanks,
Jamie
This could happen if the application, at some point, calls Application.Restart.
I am trying to get this IndexedDB stuff working in a Metro (Windows 8) app, using JS.
I thought I was good, but then I ran the WACK tool a couple of times, just to see if I ran into any issues.
After these tests the IndexedDB.open call no longer opens my database (which has 7 entries in it) instead it fires onupgradeneeded, and gives me a blank (new) database (since I create an object store in the onupgradeneeded handler).
I did not change my version number, I did not change the database name. So I am guessing the applications domain somehow changed during the WACK tests.
Does anyone now how to get my database domain back?
One of the things the WACK test probably does is doing a fresh install of the app checking if everything goes fine. So when the app is installed for the first time you have to provide a creation of the database, this is done in the onupgradeneeded event.
I think you forgot to provide this, and that is why he creates a new blank database. Instead of a new database with the required structure.
When creating Metro applications in XAML/C#, how do I detect when the application is first installed or run for the first time since installation (or potentially upgrade)? I need to use this opportunity to ensure that my database schema is correct and potentially synchronise some base data.
I had hoped that I could pick this up from the LaunchActivatedEventArgs within the OnLaunched method, but there does not seem to be a valid value for the Kind or PreviousExecutionState that I can use.
Thanks.
http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.applicationdata.localsettings.aspx#Y0
When your app starts, write a setting called "AppHasBeenStarted" or something to LocalSettings. If the setting has not already been written, you know your app hasn't been started before. And you could improve on this, by making it "AppVersion", and writing the app's version. This way your app can detect upgrades by comparing the stored version with its own version.