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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:05:33+00:00 2026-05-24T16:05:33+00:00

today I ran into a very interesting problem, which I was luckily able to

  • 0

today I ran into a very interesting problem, which I was luckily able to solve very quickly, however I’d like to know the nature of the problem.

I wrote a control class that manages joystick actions. I wanted to start some action and start the timer on button click and after the timer interval to stop this action.

I have a class(pseudocode) that looks like this :

public class Joystick : UserControl
{
  private Form.Timer timer; //or System.Threading.Timer
  public void Init()
  {
      timer.Tick += new EventHandler(timerCallback)   //Threading.Timer(timerCallback)
      timer.Stop();//timer.Change(Timeout.Infinite, Timeout.Infinite);
  }

   public void ButtonCallback()
   {
      StartSomething();
      timer.Stop();
      timer.Start(); //timer.Change(500, Timeout.Infinite); 
   }   

  public void timerCallback()
  {
     StopSomething();
     timer.Stop();//timer.Change(Timeout.Infinite, Timeout.Infinite);
  }
}

I have two applications, one is really simple (just a form), second one is more complex, however behind this complexity is still an ordinary Form (well DotNetMagicForm) containing this UserControl. Managing code is in both applications absolutely the same, but in the more complex application the timerCallback() was never called. In the simple one everything worked fine. The init was called in both cases (breakpoint). Even if I assign the timerCallback in the ButtonCallback – the timerCallback still wasn’t called.

I followed an advice of a colleague of mine and rewrote it by using Threading.Timer instead of Forms.Timer and suddenly it started working in both applications. Neither of us have a clue why it is.

I know my question is quite vague, but what could be the source of this issue?

Thanks

  • 1 1 Answer
  • 1 View
  • 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-24T16:05:35+00:00Added an answer on May 24, 2026 at 4:05 pm

    The Threading.Timer does not use a UI message pump to callback the tick. It uses a ThreadPool thread to do so.

    The UI timers simply post messages to the form’s message pump to solicit the callback. Your background magic form simply wasn’t receiving these messages. I’m never sure why though, perhaps because the form is on another thread without a message pump, or inactive forms don’t process the pump perhaps.

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

Sidebar

Related Questions

Today I ran into a very difficult TDD problem. I need to interact with
I ran into a very weird problem today. Long story short, my function returns
today I ran into this problem which really bugs me, as almost the code
An interesting problem I ran into today: what is the fastest way to count
I ran into an interesting (and very frustrating) issue with the equals() method today
I ran into an interesting SQL problem today and while I came up with
Today I ran into the following problem with NUnit. I have a class, that
I tried using PHPDoc for the first time today and quickly ran into a
I ran into a problem today trying to override an implementation of an interface
I ran into an interesting dilemma today. I have a function that handles information

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.