Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When I press the button, I call the timer'form:
VB.NET
StopWatch.Show()
'StopWatch.Timer1.Start()

When I'm finished, I'm stop the timer:
VB.NET
StopWatch.Timer1.Stop()
TextBox6.Text = StopWatch.TextBox1.Text
StopWatch.Close()


The problem is, when I start the timer with doing an operation, the timer become slower than when I call the timer form alone.

What is the problem?
Posted
Updated 12-Jun-11 20:36pm
v2
Comments
Sergey Alexandrovich Kryukov 13-Jun-11 2:40am    
Not clear. Where is the timer?
--SA
Sergey Alexandrovich Kryukov 13-Jun-11 2:43am    
What's is the type of StopWatch? System.Diagnostics.Stopwatch does not have member called Timer1. Use System.Diagnostics.Stopwatch.
--SA

Try using the StopWatch class directly.
See here[^].
 
Share this answer
 
Comments
Abdi tombang 13-Jun-11 2:30am    
Same :(
I've try to use it direcly.
But the timer still come too slow :(
Sergey Alexandrovich Kryukov 13-Jun-11 2:51am    
This is misunderstanding. What OP uses is not actually a StopWatch, hence the problem.

Please see my answer.
--SA
What you call StopWatch is not a "real" StopWatch, not System.Diagnostics.Stopwatch. I don't know what is it. See my comments to the question.

For best accuracy use
System.Diagnostics.Stopwatch.

I'm afraid you use System.Windows.Timer. If you need any reasonable accuracy, don't use this type (basically, you never need it at all); this timer is notoriously inaccurate! What you observe is maybe the effect of its low priority.

Moreover, you almost never need to use timers! In most cases, a thread is easier to implement; and the result will be much more robust; for details, please see my past answer:
Timer Threading in C#[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900