Calculate estimated time until method completion


I'm trying to calculate an estimated completion time of a method.
This means that when there are 10 inserts into the database the estimated time should popup after the first insert. The estimated time is calculated by the first insert. (9 times the first insert time).

I've tried it with a timer like

private _time;
private save_entries()

        ////insert code

the problem with this code is that the timer doesn't start in a method, only when a method is fully completed. So the timerevent is never executed. when you debug and you comment the timer1.Enabled= false line, you noticed that the debugger starts in the event after method completion

Does anybody know how to solve this issue?

I'm working in c# on a windows mobile 5.0 PDA with Compact framework 2.0 installed


Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Use following code:

DateTime dt = DateTime.Now;

//the code you want to check for speed here

DateTime dt2 = DateTime.Now;

Timer works in another way,
Timer is used to raise a timer event after Timer.Interval milliseconds
or better with:

DateTime dt = DateTime.Now;

            //the code you want to check for speed here

forget what i said comes the right one ...sorry :)))

DateTime dt = DateTime.Now;

//your code

Build an E-Commerce Site with Angular 5

Learn how to build an E-Commerce site with Angular 5, a JavaScript framework used by developers to build web, desktop, and mobile applications.

ups..another thing i forgot (it must be to early in the morning lol )

with Milliseconds you only get the milliseconds.. that means, if it takes 1 second and 33 milliseconds, it will show
"33", so you should use TotalMilliseconds this:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
You need to explorer all of the classes in the System.Diagnostics namespace.  They have specific classes meant to do what you want.  They included many performance counters and a StopWatch class.

.NET Framework Class Library  
Stopwatch Class  

Provides a set of methods and properties that you can use to accurately measure elapsed time.

Namespace: System.Diagnostics

Assuming your 2.0.

make up your mind!!!  ;-)

that's right, though, you want the TotalMilliseconds.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.