I wanted to create something similar to the way anti-virus programs sit in the Tray and can re-do an event (e.g. a scan) on an interval. I have a program that exports data from our SQL server and the user sets up a queue of what they wanted exported.
I was thinking about using System.Windows.NotifyIcon
http://msdn.microsoft.com/en-us/library/system.windows.forms.notifyicon.aspx
and
System.Timer
http://msdn.microsoft.com/en-us/library/system.timers.timer%28v=vs.71%29.aspx
Let's say the user has it set to repeat every X hours or "Every Day" or "Every Wednesday at 5:00". Should I just create a tray icon and
this.Hide();
and setup a timer that ticks and compares the time when the timer was started against whatever criteria the user set? Or, is this an inefficient and memory wasting way to do it? Is there any way to "schedule" an event to fire at a certain time and handle it that way?
You can use Windows scheduled tasks.
There is a library called Task Scheduler Managed Wrapper that can be used to set up tasks from c#.
Related
I am looking for a way to have an "alarm" type timer that throws an event at a specific system time. Is there a way to do this with UWP apps? I need my application to be able to enter "day mode" at a certain time in the day. Currently, I am using a System.Timers.Timer(), but if the computer goes into sleep mode in the middle of the timer running, it does not count sleep-mode time as part of the timed event. Is there a way to have an alarm type event that is based off of system time as opposed to "timed" time?
Is there a way to have an alarm type event that is based off of system time as opposed to "timed" time?
I have to say that the answer is no. There is no such way that could make an alarm still function in sleep mode. Even the system build-in Alarm app won't work in sleep mode.
i am working on an asp.net web application, where tasks are assigned to users, we set standard time to every task, in that standard time period the user has to finish the task, there are two buttons on the page, proceed and save, when a user clicks on proceed button, the time is saved in database as starttime, and when the user clicks on save button, the time is saved in database as endtime. this way we are capturing the time period within which the user is completing the task.
the standard time is set on an average time study basis, not every time the task takes the same amount of time.
often users can complete the task in very less time than the standard time, in this case the users are proceeding the task and even after completing the task, instead of saving it, they lock the system and go for tea breaks and after coming from break, they save the task.
i want to save some information on the web page when they lock the pc even when the browser is minimized.
i tried implementing applet using jintellitype library but its not capturing the key combinations that are used by windows os.
i also tried using Silverlight but there is no such support as in winforms application in Silverlight, i have to create a com component or something that interacts with system32 or some native api. it doesn't seem easy for me, i would like to know if there is such library for Silverlight.
it should be browser independent, i haven't tried ActiveX, but i think it can be done using ActiveX, but i don't want to use ActiveX as it runs only on IE.
i want to know all the possible solutions to achieve this.
thanks in advance.
Why don´t you set a kind of timer-check to know if the last time is too far from the correspondent (and previewed) time to perform the job? If a task may expend, for instance, from 1 to 5 minutes, have 21 minutes is too far.
Why din´t you create a timer to TIMEOUT user? If users know they will be timed-out after some time, probably, they won´t leave to coffre-break during the test (a kind of penalty must be aggregated on this, like start from the initial point if timeout).
Why don´t you automatically save the record after the job finish, instead obly the user to press a button?
Until I know, you can perform SUSPEND mode, but not detect them if started from other apps.
How can I detect if the Application has been idle for let's say 30 seconds?
I know this is possible by using a DispatcherTimer and then restarting it at PhoneApplicationPage.ManipulationCompleted event? But, I am concerned as this will affect the performance of the application.
Are there any better solutions?
You're on the right track. There isn't an explicit "idle" notification (especially not one that fast).
ManipulationCompleted may not always fire for you since other input can prevent the manipulation from starting and a user could do a very long manipulation. I'd reset the timer on any mouse input rather than just on ManipulationCompleted.
Depending on how exact you need your 30 second timer to be I would consider leaving the timer running and setting a flag for the last input. When the timer expires then check if the flag has been set. This way you won't need to continuously reset the timer for every user input.
Do we have a functionality in Windows 8 where I can set an Alarm or a Reminder (with recurrence!!) and forget about it (and the OS will do the rest)? Or do I need to create a background task to do the work?
It is not hard to schedule one event but I would not want to schedule a whole set of recurrence events.
The calendar is already doing it, can I tie into this mechanism?
You can use Scheduled Notifications but there's a limit of 4096 of those, so the recommendation for a recurring task would be to use a MaintenanceTrigger. A couple of things to be aware of:
A maintenance trigger will NOT fire if on battery power, but the
notifications are buffered so when you're plugged in again you'll
receive them.
There's up to a 15 minute window from the freshnessTime in terms
of the actual notification being triggered, so keep that in mind in
terms of scheduling. For instance, if you set a notification to
occur at noon, it might not hit until 12:14:59.
I want to create something like a client in c#.
But I do not know that how I can learn computer status like sleep mode, off, logged in or logged out.
Also, I need to get the warning if the user haven't used the computer for 10 minutes.
You can find information about currently logged user and how to hook the Locked/Unlocked events in this thread.
There are some other different approaches you might try:
You can use the System.Diagnostics and get the process list via Processes.GetProcesses(). Just keep an eye on the Idle process -- if it runs for more than 50% CPU longer than 10 mins the user seems to be idling too.
You can use Performance Counters to monitor the activity taking place on the computer and make certain decisions.
You can also use the WMI service with similar purposes.
Partial answer:
User activity/inactivity can be monitored using hooks. Start a timer with a 10-minute interval. Whenever you detect a keyboard/mouse message, restart it. If the timer event happens, than you detected 10 minutes of inactivity.