timer

How to check if user is idle on UWP? [duplicate]

无人久伴 提交于 2019-12-23 19:12:16
问题 This question already has an answer here : Detect if user Idle on windows universal app (1 answer) Closed 3 years ago . I wanted to make a function that would timeout and navigate to the main page if the user is idle for a certain period of time. After a little research, I found that the ThreadPoolTimer should suit my needs. Testing it I decided to use a 10 sec interval. timer =ThreadPoolTimer.CreatePeriodicTimer(Timer_Tick,TimeSpan.FromSeconds(10)); And this is where I'm at a loss. I couldn

How to set timer in an event handler?

不羁岁月 提交于 2019-12-23 18:15:59
问题 Am currently building an app and I want the timer to start only when I click a particular button. So is there anyway to start timer once a button is clicked? (I don't want the timer to start as soon as the page loads) 回答1: Check this post. //Inside Page Load System.Windows.Threading.DispatcherTimer dt = new System.Windows.Threading.DispatcherTimer(); dt.Interval = new TimeSpan(0, 0, 0, 0, 500); // 500 Milliseconds dt.Tick += new EventHandler(dt_Tick); Tick Event Handler for your timer void dt

How do I subscribe to raised events and printing together?

时光毁灭记忆、已成空白 提交于 2019-12-23 17:38:06
问题 I have been working on a program that has 3 classes of which 2 of the classes have timers that repeat at different intervals and once one "cycle" of the timer is done it raises an event with a string as return. The 3rd class subscribes to the events from the other two timer classes and prints them to screen. it works great! But my issue is that it is printing them separately. Lets say that the first timer class runs and then raises "hello" every 2 minutes and the other class "dog" every

How can i run php script with timer?

坚强是说给别人听的谎言 提交于 2019-12-23 17:36:05
问题 I have foreach functions that print students names $names = array("Alex","Brad","Tom"); foreach($names as $name) { echo "$name <br />"; sleep(3); } How can i print each name, each 3 seconds? After "echo $name" i need some timer to stop the loop and wait for 3 seconds. sleep() functions doesn't work here. What else i can do? 回答1: You can not do this server side (reliably). This is because there is just too much possibility of your traffic being held or buffered on the way: by the webserver, by

How to use Java.Util.Timer

无人久伴 提交于 2019-12-23 17:32:34
问题 I want to make a simple program that counts seconds up until 100 using Java.Util.Timer The code below is the code I am using, however it simply prints all the numbers out at once without waiting a second between each one. How would I fix that? (Ordinarily I would use a thread.sleep but this is just proof of concept.) import java.util.Timer; import java.util.TimerTask; public class Main { static Timer timer = new Timer(); static int seconds = 0; public static void main(String[] agrs) { MyTimer

Timer, click, mousedown, mouseup events not working together

百般思念 提交于 2019-12-23 17:13:50
问题 Looking for some help on a problem Im having sorry if this question has already been asked, I can not find anything similar. The idea is when a picturebox is clicked changed the image to ON. If the picture box is held for more than 2 seconds to open a new form and leave the picturebox as OFF. However if the picturebox is clicked ON and then held for 2 seconds and then returns i need the picturebox state to remain ON. Here is what I have tried so far. I believe for this to work correctly I

Periodic Task in Linux

我怕爱的太早我们不能终老 提交于 2019-12-23 17:00:40
问题 I want to write a C program that would periodically perform some task (say, print something on console). I have implemented it using nanosleep as below. Every 500ms the function 'func' is called. #include <stdio.h> #include <time.h> void func(void); int main() { struct timespec mytimespec; mytimespec.tv_sec = 0; mytimespec.tv_nsec = 500000000; /* 500 ms */ while(1) { func(); nanosleep(&mytimespec,NULL); } return 0; } void func(void) { printf("This would be printed periodically\n"); } Above is

Prevent AJAX Timer Control request from extending FormsAuthentication ticket?

。_饼干妹妹 提交于 2019-12-23 16:50:41
问题 I have a webforms app that uses a few ASP.NET AJAX Timer controls (i.e. polling). If a user is on a page with one of these, they will effectively never time-out, as the polling process keeps their authentication ticket alive. I'd like to segment Timer controls so they don't trigger Forms Authentication's RenewTicketIfOld method. The path I'm on and I've done something similar before is to inject something into the AJAX HTTP request to have these requests identified as coming from a timer and

How to call a method after some specific interval of time in Java

纵然是瞬间 提交于 2019-12-23 16:37:38
问题 Here is the use case: I am using Java (with Spring) Once the user (through a web-app) confirms to the subscription, I want to send him an email exactly after 30 mins. Now how to do this? Do I need a message broker? or something like ScheduledExecutorService? Do I need some sort of queue? Please advise. 回答1: Can look into quartz scheduler for this. By the way a common strategy is to send a bulk of all pending mails in bulk in every 30 minutes or so. Quartz can help in do that as well. 回答2: You

JQuery & Timer :: Updating the text of a hyperlink from a webservice

霸气de小男生 提交于 2019-12-23 16:07:15
问题 What I'm to figure out how to do is execute a webservice on a remote server to determine how many messages there are available to read and populate the text of a hyperlink with the message count. The trick is I'd like this to be fired from a timer (every 5 mins for example). Here's what I've been messing with $.ajax( {type:'Get',url:'http://foobar.com/ws',success:function(messageCount) { $('a.message').text(messageCount + ' Messages'); } }) but admittedly, am utterly clueless when it comes to