c# - How do I add a delay after a count down timer -


I use the DispatcherTimer to count one before triggering the release on a camera I'm using the UpdateCountdown method to change the displayed image before the camera's fire. Instead of having the immediately executed low picture method, I get a slight delay after reaching the counter zero and the last image is displayed.

The code shown below shows the final image on the result in the pause _countdown = 1 and TakePicture () starts flowing simultaneously (I think that takesPicture occurs first).

  _countdownTimer = New DispatcherTimer (); _countdownTimer.Interval = Timespace.formsconds (1); _countdownTimer.Tick + = New EventHahler (Representative (Objects, EventsAgps A) {UpdateContountDown ();}); _countdownTimer.Tick + = New event handler (Representative (Objects, EventsAgps A) {if (_countdown == _countdownMax) {System.Threading.Thread.Sleep (2000); / Slight delay before taking photo capture.}); } Public Zero StartCountdown () {if (doCount) {doCount = false; UpdateCountdown (); _countdownTimer.Start (); }} Private Zero UpdateCountdown () {_countdown--; Countdown = _countDownImages [_countdown]; // data is bound by image control if (_countdown == 0) {_countdown = _countdownMax; _countdownTimer.Stop (); DoCount = true; }  

What am I not taking with my time?

When you change the control properties, the UI does not update instantly - it only updates when The thread becomes useless (i.e., after executing all your event handlers).

Thread. Block the thread, event handlers do not end execution and the UI is not rebuilt.

You will need to use any other timer (start a new timer on the last ticker of the current timer and lecture on a fast New Timer Tick) or, better, the last ticker of the current timer. Use - When the URL to (_ countdown = lt; = _countdownMax) , then move it when (_ countdown == _countdownMax + 1) .


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -