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 7665109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:28:38+00:00 2026-05-31T14:28:38+00:00

I seem to have a thread issue I think, I have written a timer

  • 0

I seem to have a thread issue I think, I have written a timer to return to the main screen if its on any other screen for 5 seconds. This code works fine the first time the ResetScreen() is called, but after it returns to the main screen itself, I can’t navigate to any other screen as it keeps returning to the Timer event handler.

I also tested this without the this.Dispatcher.Invoke and replaced it with a message box, and it just constant pops up about every second.

private void ResetScreen()
{
    if (!mainScreen)
    {
        myTimer = new System.Timers.Timer();
        myTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
        myTimer.Interval = 5000;
        myTimer.Start();
    }
}

private void OnTimedEvent(object source, ElapsedEventArgs e)
{
    myTimer.Stop();
    this.Dispatcher.Invoke((Action)(() =>
    {
        // show main screen
    }));    
}

Edit:
I think its just a timer issue in general. Just can’t seem to stop the timer.

  • 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-31T14:28:40+00:00Added an answer on May 31, 2026 at 2:28 pm

    When using System.Timers.Timer() you need to explicitly set the AutoReset property to false:

    myTimer = new System.Timers.Timer();
    myTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
    myTimer.Interval = 5000;
    myTimer.AutoReset = false;
    myTimer.Start();
    

    Check out the documentation and examples on MSDN.

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

Sidebar

Related Questions

I seem to have a problem with this SQL query: SELECT * FROM appts
I seem to have the exact opposite problem than this question on stopping dock
I seem to have missed something - in this step through it talks through
I seem to have an issue with connecting to an embedded FireBird database from
I've seem to have hit a bug or i have overlooked something. I written
In my main thread I have a while(listening) loop which calls accept() on my
I seem to have a weird issue with the System.Diagnostics.Process.Start method. I have a
I seem to be having an odd issue w/ the ApplicationDeployment.CheckForUpdateAsync Method. I have
I have a problem drawing something quickly in .NET. I don't think that any
I found this thread while trying to resolve my issue unfortunately this I can't

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.