I want to make a countdown timer (lets say 20 min.) for my windows phone application. But it should still be counting down, even if the application is not active.
For example: user clicks a button, then this button should not be available for 20 min. Even if the app is restarted, the phone is restartet or whatever.
How should i basically approach this? Is the background agent the way to go? Make some kind of periodicall shedule? Or read the phone clock?
Or are there other possibilities?
It should also not be easy to avoid (for example change the time on the phone, so that it is 20 min. later on the clock)
Has someone an idea? just searching for a point in the right direction here :).
Thanks
If you don't trust the phone to provide the time of record, the obvious answer is to use a remote time server to mark application activation time according to the remote server. If you also mark the local phone time at activation and calculate the difference between the two, you can use that difference to store what the remote server would (ideally) believe to be the current time that the button is pressed without having to call the remote server again.
One example of such a service is http://www.timeapi.org/utc/now.
Related
I wrote a Windows Phone 8.1 (WINPRT) App. One of the features of this app is alarm/reminder.
For Example: user sets the Reminder at 7AM in app's Reminder Page. App must give alarm/reminder daily at 7AM. Now as I got to know, that alarm and reminder are not available in Windows Phone 8.1, so I thought of using Toast.
How will this app give a toast at user set time everyday.?
Also, how to make this app run in background for this purpose.
Any other better solution for this problem?
If your app is running a background process, it will be invoked every 30 minutes or so. You won't be able to get it to send out a toast notification exactly at 7am as far as I know, but you can get it within 15 minutes or so of 7am.
You can also schedule a toast notification to occur. Details here.
Have you looked into this?
https://msdn.microsoft.com/en-us/library/windows/apps/hh202965%28v=vs.105%29.aspx?f=255&MSPPError=-2147217396
I think this might answer your question
I am designing an application where the user selects the option to update his live tile and can forget about the app. Once he picks the option to update, I kick off a background task agent. But it looks like as per msdn, the background task agent will only run for upto two weeks.
How do I fire it again without having the user to come into the app?
It's not possible to run a Background Agent without rescheduling it every 14 days. Moreover, if the phone is in the battery-saving mode, it may not run the agent. So, you should find a better way to update the tile (Tile Push Notification).
Or, if you want to go with the Bckground Agent, the day before expiring, update the tile saying that the user should open the app to continue getting the tile updated. But, if he info is useful, the user will tap on the tile to get more info.
This has changed in Windows Phone 8. If the user has chosen your app for any of the lockscreen settings (Background, Content, or Status) the app will continue to run after the two weeks without the need for a launch by the user.
So if you have an application that the user decides to use as a part of their lock screen you are ok.
Otherwise I would go with setting a reminder the day you are going to expire. Each time the app is launched delete the reminder and make a new one two weeks out.
I also liked one of the comments above to change your tile status to "Launch me to get more updates".
I want to make a application that runs with no form interaction with user and only specific person can run a form and change config setting. The application is desktop reminder which runs every 4 months and shows up a notification.
I don't have any idea how to start it. Please guide me with some good suggestions.
If you have an application that needs to notify the user once every 4 months, its a bit overhead to have it running all the time.
Use the Task Scheduler in Windows, to schedule this command to run (once per day, or every week) check if the condition is met. If not silently exit.
You can effectively create a windows Service and then configure it to allow it interact with the desktop through the Services administration console.
However, for security reasons in W2008 Server (and I assume that more or less it will be the same with W7 or even Vista, you'll have to try it) this behaves differently, and services that interact with the desktop are not allowed. Actually, I remember that when I created and showed a Window I got a notification and when clicking on it the desktop switched to another one with my window. Still, no issue with XP, I've done it.
The desktop application is being developed with a demo version that is supposed to run for a few minutes and after that would request the user to restart the application to run again (the user has to input their login and password to access it), since I dont know much in this field the way I can think of doing this without the user bypassing it would be having a realtime communication between both or something of the sorts.
After X minutes the server sends a
message to the client to close/disable
the client requiring the user to
restart it, it also limits the daily
usage on the demo for the same user.
As I am very inexperienced in this type or communication I would like to consult you guys with what options I have here ?
The desktop application is developed in c# to run mainly on windows OS as for the server we only have linux available and as to what sort of service, if it is possible to make a webapi or session in php or perl to work with it that would be reliable enough would be nice but if that is not possible we are open to hear other options.
PS: If I have'nt given enough information or am missing anything important here please drop me a comment i will update as soon as possible.
I'd give a go to HTTPS with mutual certificate-based authentication as the safest option. The desktop app can poll the server (=ask periodically) and quit in case of no response / no connection / negative reponse.
However, based on the type of app you are developing and the target audience, you can expect an important amount of users to have connectivity problems or have no connectivity at all.
Because of this, at the end of the day, you can come up with a lot simpler solution, like measuring run-time locally without any server involved, and gain pretty much the same effect.
I don't think you need to involve a server to do this.
Just have the desktop application save the date and time when it started. Periodically on a timer you can check the current time, and see if too much time has elapsed for the demo version, and tell the user they have to quit.
It is very unlikely many users will try to get around this. They are more likely to dump your trial software in favour of something that treats them decently!
Checking DateTime.Now could work as Ben stated, but you'd be better off with System.Timers.Timer. Set interval to be your desired interval between auth calls in milliseconds. Attach a handler to the elapsed event that asks for auth info. System.Timers.Timer works in a separate thread so you can take advantage of some parallelism here. Changing the system time shouldn't have any effect on System.Timers.Timer but I am not positive on that point.
I once used a command line SMTP mailer that, as a limit of the trial version, allowed you to receive up to 10 emails with it per Windows session. If you rebooted your computer, you could receive 10 more. I thought this kind of shareware crippling was pretty neat, and I'd like to replicate it in my app.
I'm just stuck on how to do it. I know how to limit the user's actions, but how can I tell if the computer has been restarted since the application has been last run?
The OS is Windows and the language is C#.
You should be able to find events in the event log, such as the event log service start that would tell you if the computer has restarted.
Here's how to read the event log in C#:
http://msdn.microsoft.com/en-us/library/k6b9a7h8%28VS.71%29.aspx
// C#
foreach (System.Diagnostics.EventLogEntry entry in EventLog1.Entries)
{
Console.WriteLine(entry.Message);
}
Note: you should provide the language and OS you are using.
If you're using .NET, you can use Environment.TickCount for this. This gives you the number of ms since the system started. Note that it rolls over every ~24 days, so you'll have to compensate for that (if you care).
For Windows, if you want to check the computer booted
Type on the Command Prompt
C:\>net statistics server
One of the statistics will be
Statistics since 22-Jun-11 10:46:20 which was the last time the computer booted
For Windows platform you can use uptime.
C:\>uptime
\\SPOCK has been up for: 2 day(s), 0 hour(s), 45 minute(s), 34 second(s)
The answer above is for Pre-Windows Server 2008 systems, but for Windows 2008 there is a much easier way of finding the uptime for a Windows 2008 server.
Task Manager > Performance > Up Time
Couldn't you just keep a counter of the number of events your application has performed. And then stop when the counter reached threshold? If your application contains a service then it could be embedded as part of the service which would be restarted with the windows sessions. I suspect that is how the SMTP server worked, at least that is the simplest way that I would implement something like that. It would keep most novice/intermediate system admins restarting the box, and the smart ones probably deserve to have the software for free anyway.