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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:50:00+00:00 2026-05-30T16:50:00+00:00

I am using a Dispatch timer set to fire every 20 seconds in which

  • 0

I am using a Dispatch timer set to fire every 20 seconds in which I need to update a databound textblock via it’s propery in my view model. This is the timer code in the viewmodel:

public TestViewModel()
  {
     _dispatcherTimer = new DispatcherTimer();
     _dispatcherTimer.Interval = new TimeSpan(0, 0, 20);
     _dispatcherTimer.Tick += new EventHandler(_dispatcherTimer_Tick);
     _dispatcherTimer.Start();    
  }

void _dispatcherTimer_Tick(object sender, EventArgs e)
    {
        if(blah == blah)
        {
        _dispatcher.BeginInvoke(() => 
                      {
                           // DoneEnabled is a boolean property that my 
                           // textblock's IsEnabled property is bound to   
                           DoneEnabled = true;  
                      });
         }
    }

private bool _doneEnabled;    

    /// <summary>
    /// Gets or sets a value indicating whether [done enabled].
    /// </summary>
    /// <value>
    ///   <c>true</c> if [done enabled]; otherwise, <c>false</c>.
    /// </value>
    public bool DoneEnabled
    {
        get { return _doneEnabled; }
        set
        {
            _doneEnabled = value;
            RaisePropertyChanged("DoneEnabled");
        }
    }

The button gets enabled everywhere else when I try and do so in my viewmodel by updating this property EXCEPT in the timer’s event handler. Any idea if I’m missing something here?

Thanks.

UPDATE:

Edited the _dispatcherTimer_Tick method to the following

void _dispatcherTimer_Tick(object sender, EventArgs e)
    {
        if(blah == blah)
        {           
          // DoneEnabled is a boolean property that my 
          // textblock's IsEnabled property is bound to   
             DoneEnabled = true;  

         }
    }

Works like a charm!

  • 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-30T16:50:01+00:00Added an answer on May 30, 2026 at 4:50 pm

    Since you are using a DispatchTimer the method _dispatcherTimer_Tick already runs on the UI/Dispatcher thread (this is built in for convenience of use) – just do:

    void _dispatcherTimer_Tick(object sender, EventArgs e)
    {
        if(blah == blah)
        {
            DoneEnabled = true;  
        }
    }
    

    From MSDN:

    Reasons for using a DispatcherTimer opposed to a System.Timers.Timer
    are that the DispatcherTimer runs on the same thread as the Dispatcher
    and a DispatcherPriority can be set on the DispatcherTimer.

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

Sidebar

Related Questions

I'm creating a styled QTreeView using double-dispatch to resolve specific delegate for data items,
In the example for coding with Json using Databinder Dispatch Nathan uses an Object
Using JDeveloper , I started developing a set of web pages for a project
I maintain a dispatch queue as a property with my view controller. I create
I'm first timer to Ruby on Rails, trying to set it up on RHEL
Following scenario. Real time camera feed processing with openCV on ios using dispatch asnyc.
Occasionally, it's useful to set up method dispatch table so calling method A calls
Simple php/mysql INSERT such as mysql_query(INSERT INTO dispatch VALUES('1234','$name','$address')); intermittently fails. I've set it
I have a classic asynchronous message dispatching problem. Essentially, I need to asynchronously dispatch
I use the following code to update my progressBar when using min and max

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.