Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 800211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:15:29+00:00 2026-05-14T23:15:29+00:00

I want to use a timer only once, at 1 second after the initialization

  • 0

I want to use a timer only once, at 1 second after the initialization of my main form.
I thought the following would have a message box saying “Hello World” just once, but actually a new message box says “Hello World” every one second.

Why so? I had put t.Stop() in the tick event.
Also, do I need to dispose the timer somehow to avoid memory leakage?

        Timer t = new Timer();
        t.Interval = 1000;                
        t.Tick += delegate(System.Object o, System.EventArgs e)
                        { MessageBox.Show("Hello World"); t.Stop(); };

        t.Start();   

Please help and show if there is a better way of doing this?
Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T23:15:30+00:00Added an answer on May 14, 2026 at 11:15 pm

    Replace MessageBox.Show("Hello World"); t.Stop(); with t.Stop();MessageBox.Show("Hello World");. Because you’re not pressing OK in time, the timer has already ticked again and you never reached the stop code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a global form which I want to use the same form every
I am using MSP430F5418 with IAR EW 5.10 . I want to use Timer
How can I use variables to set my timer? I want to control delay
I was creating a countdown timer using javascript; I can use jQuery. I want
I want to use boost::timed_wait to wait for an event or to timeout after
I'm having a problem with the following code. I want to use one UIImageView
I want to use barplot() to plot a time series xts object. However, the
I want to use multiple calendars and lose the time axis in the agenda
I want to use javascript in my webpage to print time such as 8:40
For the first time i use eclipse with m2e and i want to configure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.