dispatchertimer

how to make DispatcherTimer events smoother in WPF?

谁说胖子不能爱 提交于 2020-01-11 02:04:11
问题 In my WPF application, the user presses a button to start a 3D model rotating smoothly, and lets up on the button to stop the rotation. To do this, I create a DispatcherTimer: DispatcherTimer timer = new DispatcherTimer(); timer.Tick += new EventHandler( timer_Tick ); timer.Interval = new TimeSpan( 0, 0, 0, 0, 30 ); And when the button is pressed I call timer.Start() and when the button is let up I call timer.Stop() . The timer_Tick function changes the rotation of the model: void timer_Tick(

send a extra argument in Dispatchertimer.Tick event

扶醉桌前 提交于 2020-01-02 03:00:14
问题 my question is how can i send some arguments in Dispatchertimer.Tick event here is the code: what i wanted to is receive a integer value at dispatcheTimer_Tick dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick); private void dispatcherTimer_Tick(object sender, EventArgs e) { //.Text = DateTime.Now.Second.ToString(); } what i wanted to do is something like this private void dispatcherTimer_Tick(object sender, EventArgs e,int a) { //.Text = DateTime.Now.Second.ToString(); } how to

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

how to show label for couple of seconds in wpf?

烂漫一生 提交于 2019-12-24 10:39:25
问题 i want to show a label for a 3 seconds only and then disappear it. i am working in wpf application. public DispatcherTimer timer = new DispatcherTimer(); timer.Tick += new EventHandler(timer_Tick); i started timer from the function timer.Start(); private void timer_Tick(object sender, EventArgs e) { /* if timer equals 3 seconds then timer.stop(); lblToast.Visibility = Visibility.Hidden; else lblToast.Visibility = Visibility.Visible; */ } is this right way ? or is there any other easy way ?

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); //

Using ThreadPoolTimer with Background Audio UWP

早过忘川 提交于 2019-12-12 09:24:00
问题 I am making a UWP app using the BackgroundAudioTask. My app is working very well. Now I want to add in a TextBlock the Current position of the Audio played. I was doing this method before implementing the audio Task: private TimeSpan TotalTime; private DispatcherTimer timerRadioTime; private void radioPlayer_MediaOpened(object sender, RoutedEventArgs e) { TotalTime = radioPlayer.NaturalDuration.TimeSpan; // Create a timer that will update the counters and the time slider timerRadioTime = new

Dispatcher Timer freezing the WPF

你。 提交于 2019-12-12 00:09:59
问题 I am designing a 3 DOF control application for AR Drone (quad-rotor UAV) .. i am using multiple PID controllers to control the UAV .. these controllers are implemented by using dispatcher timer class .. for example at the start of the program I initialize the dispatcher timer like : timer_yaw = new DispatcherTimer(); timer_yaw.Interval = new TimeSpan(0, 0, 0, 0, 45); timer_yaw.Tick += new EventHandler(timer_yaw_tick); as soon as the user presses a button on the GUI this timer is fired . timer

Most efficient method to update large number of objects (1,000+) in real-time

自古美人都是妖i 提交于 2019-12-10 10:17:17
问题 What would be the most efficient way to iterate through a collection with a large number of items (1,000 or more) and update the items' properties in real-time? At the moment, my program draws an image for each object in the collection on a canvas using WriteableBitmap (though I don't see any difference in performance between that an a simple ellipse) and moves it across the screen. I am trying to keep the logic as simple as possible for the time being. <UserControl.Resources> <DataTemplate

Task.Delay vs DispatcherTimer?

倾然丶 夕夏残阳落幕 提交于 2019-12-08 15:33:14
问题 I'm considering use Task.Delay() for a non-stop timer, because it's more simple and readable. As I'm new to .NET, I see no significant difference between the two codes. Can you show me the difference (if there is any) between them? // Create variable at some place DispatcherTimer timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromSeconds(5); timer.Tick += timer_Elapsed; timer.Start(); // Function other place void timer_Elapsed(object sender, EventArgs e) { //Do stuff } vs // Every

Most efficient method to update large number of objects (1,000+) in real-time

三世轮回 提交于 2019-12-05 20:58:38
What would be the most efficient way to iterate through a collection with a large number of items (1,000 or more) and update the items' properties in real-time? At the moment, my program draws an image for each object in the collection on a canvas using WriteableBitmap (though I don't see any difference in performance between that an a simple ellipse) and moves it across the screen. I am trying to keep the logic as simple as possible for the time being. <UserControl.Resources> <DataTemplate DataType="{x:Type local:Entity}"> <Canvas> <Image Canvas.Left="{Binding Location.X}" Canvas.Top="