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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:41:00+00:00 2026-05-16T22:41:00+00:00

In WPF due to the intricacies on how the interface is updated I sometimes

  • 0

In WPF due to the intricacies on how the interface is updated I sometimes have to perform actions after a short delay.

Currently I’m doing this simply by:

        var dt = new DispatcherTimer(DispatcherPriority.Send);
        dt.Tick += (s, e) =>
        {
            dt.Stop();
            //DoStuff
        };
        dt.Interval = TimeSpan.FromMilliseconds(200);
        dt.Start();

But it’s both a bit ugly and perhaps too much overhead to create a new timer each time (?)
What’s the best from a performance standpoint to do it, ie execute most promptly? And what’s good way to rewrite the above code into something like:

        this.Dispatcher.BeginInvoke(new Action(delegate()
        {
            //DoStuff
        }), DispatcherPriority.Send,TimeSpan.FromMilliseconds(200));

Where Timespan is the delay, Thanks for any input 🙂

  • 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-16T22:41:00+00:00Added an answer on May 16, 2026 at 10:41 pm

    I wouldn’t assume that the DispatcherTimer is heavy-weight… why not just write an extension method on Dispatcher which allows you to use the syntax you want, and uses a DispatcherTimer in the background? I would personally call it DelayInvoke rather than BeginInvoke though… and I’d also fix it to always use Action rather than an arbitrary delegate… that will make it easier to use lambda expressions:

    Dispatcher.DelayInvoke(TimeSpan.FromMilliseconds(200), () => { ... 
    });
    

    (I tend to find it’s more readable if anonymous functions are used as the final argument in a method call, but that’s just a personal preference.)

    Given that you’ll quite possibly want to use milliseconds most of the time, you could have another helper method too:

    Dispatcher.DelayInvokeMillis(200, () => { ... 
    });
    

    Another alternative to try is merely to use the existing BeginInvoke method but with a very low priority, so your delegate will only be invoked after everything else has finished. Without knowing the details of your situation, it’s hard to know whether that’ll work or not – but it’s worth trying.

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

Sidebar

Related Questions

Recently there have been a lot of move towards MVVM framework due to the
I'm using WPF and C#. I want to be able to launch a browser
currently im taking a Master degree course in Computer Sciences, and i´d like to
Hey folks, hoping you can help me get started with IronRuby. I have several
WPF is promising us a lot of niceties, but some of them don't live
I'm adding C# WPF dialogs to an existing C++ MFC app, using a C++/CLI
Im building a wpf app with the composite application block (prism) V2, and Im
I am having a frustrating time with Blend reporting Window is not supported in
There a lot of different ways a Silverlight application can connect back to it’
I'm looking for some arguments to pitch to my boss and fellow developers. We're

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.