Avatar of zell71
zell71Flag for United Kingdom of Great Britain and Northern Ireland asked on

Timer Function Question

how can i use a timer to count how long it takes to return search data?
i.e MessageBox.Show ("Your search took XXX seconds/minutes to return data", Timer1)
?how do i implement this?
cheers
.NET Programming

Avatar of undefined
Last Comment
zell71

8/22/2022 - Mon
SOLUTION
Bruce_1975

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER CERTIFIED SOLUTION
CuteBug

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
zell71

gave more points to CuteBug as thats the answer i used, cheers
ASKER
zell71

This is the full coded using answers above, cheers
private void ShowDateSystemLogErrors_Click(object sender, EventArgs e)
        {
            DateTime dt = dateTimePicker1.Value;
            // Change to hourglass whilst working
            this.Cursor = Cursors.WaitCursor;
 
            try
            {
                Stopwatch stopwatch = new Stopwatch();
                // start the stopwatch
                stopwatch.Start();
                
                // Complete the search and return a list
                this.SystemLogErrorsView.DataSource = this._Errors.GetByDate(dt);
                
                // stop the stopwatch
                stopwatch.Stop();
 
                // Get the elapsed time as a TimeSpan value
                TimeSpan ts = stopwatch.Elapsed;
 
                // Timewatch string formatting
                string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}", ts.Hours, ts.Minutes, ts.Seconds / 10);
                MessageBox.Show(string.Format("The Search Took {0} to Complete", elapsedTime));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
 
            // Change back to arrow cursor
            this.Cursor = Cursors.Default;
        }

Open in new window

All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck