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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:59:53+00:00 2026-06-11T00:59:53+00:00

I have a project here and it has set by default that the actions

  • 0

I have a project here and it has set by default that the actions occur by MouseEnter event. I mean, opening a Window, closing, returning, whatever, happens only by the MouseEnter event.

I was requested to make the event fire only after 3 seconds. That means that the user will place the mouse on the control and only after 3 seconds the event must happen for all the controls in the window.

So, I thought about a global timer or something alike, that will return false untill the timer reaches 3… I think that’s the way…

Geez, does anybody knows how can I make such thing?

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-06-11T00:59:55+00:00Added an answer on June 11, 2026 at 12:59 am

    You can define a class that will expose a DelayedExecute method that receives an action to execute and creates timers as needed for the delayed execution. It would look something like this:

    public static class DelayedExecutionService
    {
        // We keep a static list of timers because if we only declare the timers
        // in the scope of the method, they might be garbage collected prematurely.
        private static IList<DispatcherTimer> timers = new List<DispatcherTimer>();
    
        public static void DelayedExecute(Action action, int delay = 3)
        {
            var dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
    
            // Add the timer to the list to avoid it being garbage collected
            // after we exit the scope of the method.
            timers.Add(dispatcherTimer);
    
            EventHandler handler = null;
            handler = (sender, e) =>
            {
                // Stop the timer so it won't keep executing every X seconds
                // and also avoid keeping the handler in memory.
                dispatcherTimer.Tick -= handler;
                dispatcherTimer.Stop();
    
                // The timer is no longer used and shouldn't be kept in memory.
                timers.Remove(dispatcherTimer);
    
                // Perform the action.
                action();
            };
    
            dispatcherTimer.Tick += handler;
            dispatcherTimer.Interval = TimeSpan.FromSeconds(delay);
            dispatcherTimer.Start();
        }
    }
    

    Then you can call it like this:

    DelayedExecutionService.DelayedExecute(() => MessageBox.Show("Hello!"));
    

    or

    DelayedExecutionService.DelayedExecute(() => 
    {
        DoSomething();
        DoSomethingElse();
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Project entity that has a set of Word entities within. My
I have a bare-bones sample project here: http://dl.dropbox.com/u/7834263/ExpandingCells.zip In this project, a UITableView has
I have a gwt project that uses gwt-mosaic. Here is the error message I
I have a project that has existed for quite a while, and I recently
I have a function that has an optional variable myFont . By default, it's
I have a project here the goal is to merge multiple Access DB's into
I have a sample project here on github where I created a c++ wrapper
This is my first windows application. I have published my project and here are
Here's what i'm trying to do. I have a project in /var/www/project. I'd like
Here is my scenario: I have an Eclipse project in my desktop in a

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.