timer

Equivalent to javax.swing.Timer in Android

余生长醉 提交于 2019-12-19 03:37:07
问题 Is there something that looks like the javax.swing.Timer on Android. I know how to create own Threads, but is there something that is like the swing-timer? 回答1: There is also Java's TimerTask. Here's an example from my code where I'm playing audio samples: import java.util.Timer; import java.util.TimerTask; // from constructor, shown here out of place timer = new Timer(); // and in method, again, shown out of place: INTERVAL_MILLISECONDS = (int)((double)(bufSize) / (double)(nativeSampleRate *

DispatcherTimer doesn't work in Console

故事扮演 提交于 2019-12-19 03:36:48
问题 I'm curious as to why dispatcher timer doesn't work in console mode. I created a simple alarm that does something when the timer reaches it's limit. Can you use dispatcher timer with UnitTest or in Console mode? DailyAlarm works when I run it in a form. Here's my code to call the timer [TestClass] public class UnitTest1 { bool runTest = true; [TestMethod] public void TestDailyAlarm() { DateTime alarmTime = new DateTime(); alarmTime= DateTime.Now; alarmTime = alarmTime.AddSeconds(5); //

How to have a WPF binding update every second?

爷,独闯天下 提交于 2019-12-19 01:48:07
问题 I want to show the user how many seconds have passed since some event occurs. Conceptually, my view model has properties like this: public DateTime OccurredAtUtc { get; set; } public int SecondsSinceOccurrence { get { return (int)(DateTime.UtcNow - OccurredAtUtc).TotalSeconds; } } If I bind a TextBlock.Text property to SecondsSinceOccurrence , the value appears but it is static. The passing of time does not reflect the increasing age of this event. <!-- static value won't update as time

How to have a WPF binding update every second?

随声附和 提交于 2019-12-19 01:46:07
问题 I want to show the user how many seconds have passed since some event occurs. Conceptually, my view model has properties like this: public DateTime OccurredAtUtc { get; set; } public int SecondsSinceOccurrence { get { return (int)(DateTime.UtcNow - OccurredAtUtc).TotalSeconds; } } If I bind a TextBlock.Text property to SecondsSinceOccurrence , the value appears but it is static. The passing of time does not reflect the increasing age of this event. <!-- static value won't update as time

How to run scheduled tasks in Orchard?

 ̄綄美尐妖づ 提交于 2019-12-18 17:23:05
问题 I have to run a automated job every 5 hours. I found this post on how to create scheduled tasks, using IScheduledTaskHandler and IScheduledTaskManager. Scheduled tasks using Orchard CMS I copied the same code, I added my service call inside the Process function. It compiles fine. But I am not sure if I have to 'start' this scheduled task, like a windows service start. Does it get picked up automatically after I build the solution? When does the clock starts ticking if I want to run this job

Execute an operation every x seconds for y minutes in c#

大城市里の小女人 提交于 2019-12-18 16:13:30
问题 I need to run a function every 5 seconds for 10 minutes. I use a timer to run it for 5 secs, but how do I limit the timer to only 10 mins? 回答1: Just capture the time that you want to stop and end your timer from within the elapsed handler. Here's an example (note: I used a System.Threading.Timer timer . Select the appropriate timer for what you are doing. For example, you might be after a System.Windows.Forms.Timer if you are writing in Winforms.) public class MyClass { System.Threading.Timer

Activiti / Camunda change boundary timer with variable

穿精又带淫゛_ 提交于 2019-12-18 13:37:52
问题 I got a special question regarding timer boundary events on a user task in Activiti/Camunda: When starting the process I set the timer duration with a process variable and use expressions in the boundary definition to resolve the variable. The boundary event is defined on a user task. <bpmn2:timerEventDefinition id="_TimerEventDefinition_11"> <bpmn2:timeDuration xsi:type="bpmn2:tFormalExpression">${hurry}</bpmn2:timeDuration> </bpmn2:timerEventDefinition> In some cases, when the timer is

How do I obtain CPU cycle count in Win32?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-18 13:23:30
问题 In Win32, is there any way to get a unique cpu cycle count or something similar that would be uniform for multiple processes/languages/systems/etc. I'm creating some log files, but have to produce multiple logfiles because we're hosting the .NET runtime, and I'd like to avoid calling from one to the other to log. As such, I was thinking I'd just produce two files, combine them, and then sort them, to get a coherent timeline involving cross-world calls. However, GetTickCount does not increase

Executing method every hour on the hour

微笑、不失礼 提交于 2019-12-18 13:19:09
问题 I want to execute a method every hour on the hour. I wrote some code,but it is not enough for my aim. Below code is working every 60 minutes. public void Start() { System.Threading.Timer timerTemaUserBilgileri = new System.Threading.Timer(new System.Threading.TimerCallback(RunTakip), null, tmrTemaUserBilgileri, 0); } public void RunTakip(object temauserID) { try { string objID = "6143566557387"; EssentialMethod(objID); TimeSpan span = DateTime.Now.Subtract(lastRunTime); if (span.Minutes > 60)

STL Priority Queue - deleting an item

泪湿孤枕 提交于 2019-12-18 12:58:23
问题 I want to implement a timer queuing system using the C++ STL priority_queue container adapter. My problem is that I want to occasionally cancel a timer, however there are no interfaces that enable me to easily delete an item in the priority_queue that is not the top item. Any suggestions?. Thank you for your help. 回答1: I had the exact same scenario once and did the following: the structure I kept in std::priority_queue contained only the time to sort by and an index to a std::vector<Handler>