timer

Difference between DispatchSourceTimer, Timer and asyncAfter?

耗尽温柔 提交于 2019-12-31 09:13:07
问题 I am struggling to understand the key differences between DispatchSourceTimer, Timer and asyncAfter ( in my case for scheduling a task that needs to be ran every X seconds, although understanding the differences in timers can be useful to ) (Or is there another (more efficient) scheduling mechanism in Swift besides the listed timers?). A Timer needs an active run loop on the current queue it was started on. A DispatchSourceTimer does not need that. A Timer keeps the CPU from going into the

Creating a c# windows service to poll a database

非 Y 不嫁゛ 提交于 2019-12-31 08:54:45
问题 I am wanting to write a service that polls a database and performs an operation depending on the data being brought back. I am not sure what is the best way of doing this, I can find a few blogs about it and this stack overflow question Polling Service - C#. However I am wary that they are all quite old and possibly out of date. Can anyone advise me on the current advice or best practices (if there are any) on doing something like this or point me in the direction of a more recent blog post

Creating a c# windows service to poll a database

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-31 08:54:07
问题 I am wanting to write a service that polls a database and performs an operation depending on the data being brought back. I am not sure what is the best way of doing this, I can find a few blogs about it and this stack overflow question Polling Service - C#. However I am wary that they are all quite old and possibly out of date. Can anyone advise me on the current advice or best practices (if there are any) on doing something like this or point me in the direction of a more recent blog post

Timer for traffic lights c#

时光毁灭记忆、已成空白 提交于 2019-12-31 07:43:11
问题 i have wrote the code for a simple traffic light app with wpf elements. I use the timer function. The app works without any exception, but the wanted function isnt there. It only flashes the red or the orange light. I sit for 3 hours and now brain is empty. I try and try without any change. Can you help me please to fix the problem and learn how to use the timer correct? Thanks a lot using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading

Countdown Timer Excel VBA - Code crashed excel

随声附和 提交于 2019-12-31 07:22:17
问题 Could someone offer an insight into why this crashes my excel, i cant seem to work it out. Im trying to learn VBA and need some advice. sub timer() dim second second = 1.15740740740741e-05 'this is the amount excel counts as a second line1: application.wait "00:00:01" Range("a1").value = Range("a1").value - second if not range("D2").value = 0 then Goto line1 else Msgbox("Countdown ended") End if end sub 回答1: I'm sure you're not timing space shuttle launches or anything that critical. But if

can't sort files from folder in String[] Array

[亡魂溺海] 提交于 2019-12-31 06:23:38
问题 my project is about recording screen as sequence of images then instead of make it as video i planed to load all image directories to list and use timer to view them image by image, but i get files in wrong order like this: this code is to load files from directory: string[] array1 = Directory.GetFiles("C:\\Secret\\" + label1.Text, "*.Jpeg"); Array.Sort(array1); foreach (string name in array1) { listBox1.Items.Add(name); } timer2.Start(); this code to view them int x = 0; private void timer2

C# Timer and memory leak

雨燕双飞 提交于 2019-12-31 05:38:11
问题 I am creating a program that will check for directory listing every 2 seconds. I expect this program to run for months without leaking memory or requiring any human interaction. Below program has memory leak. I am still not sure what the 10K represents. It is not the interval. The interval is 2k. class Program { static void Main(string[] args) { Timer aTimer = new Timer(10000); aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent); aTimer.Interval = 2000; aTimer.Enabled = true; Console

Print out a warning every whole second in Matlab

允我心安 提交于 2019-12-31 04:51:08
问题 I am trying to print a warning or just a message after every second, like "1 second elapsed". Is there a possibility to realize that? I tried it with tic toc and a loop, but it is pretty insufficient. Furthermore I never get exactly one second. Is there a command that prints every X ms automatically? Any ideas? Thanks in advance. 回答1: Use a timer object. t = timer; t.ExecutionMode = 'fixedRate'; t.Period = 1; t.TimerFcn = @(~,~)disp('1s elapsed'); start(t) 回答2: As @Daniel suggested, timer

How to run a function after a given amount of time in tkinter?

回眸只為那壹抹淺笑 提交于 2019-12-31 03:25:09
问题 So I have a .gif picture on a canvas in tkinter. I want this picture to change to another picture...but only for 3 seconds. and for it revert back to the original picture. def startTurn(self): newgif = PhotoImage(file = '2h.gif') self.__leftImageCanvas.itemconfigure(self.__leftImage, image = newgif) self.__leftImageCanvas.image = newgif while self.cardTimer > 0: time.sleep(1) self.cardTimer -=1 oldgif = PhotoImage(file = 'b.gif') self.__leftImageCanvas.itemconfigure(self.__leftImage, image =

My Timer event crashes because the events are called on a different thread

六眼飞鱼酱① 提交于 2019-12-31 03:11:07
问题 I get the error "Cross-thread operation not valid: Control 'label1' accessed from a thread other than the thread it was created on." when I run this code: using System; using System.ComponentModel; using System.Data; using System.Text; using System.Windows.Forms; using System.Timers; namespace WindowsFormsApplication1 { public partial class Form1 : Form { System.Timers.Timer T = new System.Timers.Timer(); public Form1() { InitializeComponent(); T.Elapsed += new ElapsedEventHandler(T_Elapsed);