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

  • Home
  • SEARCH
  • 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 6332783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:20:59+00:00 2026-05-24T18:20:59+00:00

I have a wpf application and in that application i have a button and

  • 0

I have a wpf application and in that application i have a button and a textblock. I have cliked the button and in the event responder i have done a simple looping. In that loop i have waited for 2 second and after the waiting i have updated the text of the textblock but it seems that the textblock is not updating with the text. Rather it is updated once(at the last time with the first item tex). Can anyone know.. how to update the textblock in a loop ….

public partial class MainWindow : Window
{
    List<String> list;

    public MainWindow()
    {
        InitializeComponent();
        LoadList();
    }



    private void LoadList()
    {
        list = new List<string>();
        list.Clear();
        list.Add("Chisty");
        list.Add("Forkan");
        list.Add("Farooq");
    }



    private void BtnClickHandler(object sender, RoutedEventArgs e)
    {
        for (int i = 0; i < 3; i++)
        {                
            System.Threading.Thread.Sleep(5000);  // wait for 5 second
            textBlock1.Text = list[i].ToString(); // assign a new text to the textblock
            System.Console.WriteLine(list[i].ToString());
        }
    }
}
  • 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-24T18:21:00+00:00Added an answer on May 24, 2026 at 6:21 pm

    To notify the change you need to implement the Dispatcher
    Try this…

    private void BtnClickHandler(object sender, RoutedEventArgs e)
        {
            for (int i = 0; i < 3; i++)
            {                
                System.Threading.Thread.Sleep(5000);  // wait for 5 second
                textBlock1.Text = list[i].ToString();
                DoEvents();
                System.Console.WriteLine(list[i].ToString());
            }
        }
    
    
    
      public void DoEvents()
        {
            DispatcherFrame frame = new DispatcherFrame(true);
            Dispatcher.CurrentDispatcher.BeginInvoke
            (
            DispatcherPriority.Background,
            (SendOrPostCallback)delegate(object arg)
            {
                var f = arg as DispatcherFrame;
                f.Continue = false;
            },
            frame
            );
            Dispatcher.PushFrame(frame);
        } 
    

    You can see more information in Implement Application.DoEvents in WPF

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

Sidebar

Related Questions

I have a simple WPF application that uses ClickOnce to handle installing. Within this
I have a simple message box in a WPF application that is launched as
I have a WPF application that has just one button. When the button is
I have a wpf application that has a button for for each folder under
This is C# WPF application. I have a Button that close the application. Is
I a WPF application I have the following event-handler of a button-click in a
I have a chromeless button in a WPF application that uses the XAML style
I have a WPF C# application that contains a button. The code of the
I have a small WPF application. This application has a button that when clicked,
I have a WPF application that runs fine under XP as an administrator. When

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.