---
title: "WPF Progressbar"  
description: "WPF Progressbar"  
author: "Anonymous User"  
published: 2013-09-24  
updated: 2013-09-24  
canonical: https://www.mindstick.com/forum/1521/wpf-progressbar  
category: "wpf"  
tags: ["wpf"]  
reading_time: 2 minutes  

---

# WPF Progressbar

In my WPF [application](https://www.mindstick.com/articles/12824/calculator-application-in-android) i have to show a progressbar progress with in a timer tick event, which i am [writing as](https://answers.mindstick.com/qa/94007/why-did-you-choose-content-writing-as-a-profession) below,

System.Windows.Forms.Timer timer;

public MainWindow()

{

timer = new System.Windows.Forms.Timer();

timer.Interval = 1000;

this.timer.Tick += new System.EventHandler(this.timer_Tick);

}

load event as below

[private](https://www.mindstick.com/blog/11097/java-access-modifiers-the-public-and-the-private-modifiers) void Window_Loaded(object sender, RoutedEventArgs e)

{

progressBar1.Minimum = 0;

progressBar1.Value = DateTime.Now.Second;

progressBar1.Maximum = 700;

timer.Start();

}

And at last in tick event,

private void timer_Tick(object sender, EventArgs e)

{

[Duration](https://answers.mindstick.com/qa/45301/what-is-a-short-duration-discussion) duration = new Duration(TimeSpan.FromSeconds(20));

//[progress bar](https://www.mindstick.com/articles/12747/android-progress-bar) [animation](https://www.mindstick.com/articles/13040/seven-helpful-tips-to-start-and-grow-an-animation-video-company)

System.Windows.Media.Animation.DoubleAnimation doubleanimation = new System.Windows.Media.Animation.DoubleAnimation(200.0, duration);

progressBar1.BeginAnimation(ProgressBar.ValueProperty, doubleanimation);

}

When i [execute](https://www.mindstick.com/interview/49/how-can-i-execute-a-php-script-using-command-line) my program progressbar shows the progress for two-three bars and then it stops increment. Later there is no effect in the progress at all. What [went wrong](https://answers.mindstick.com/qa/94671/how-do-i-create-a-google-account-when-the-page-keeps-showing-me-a-message-that-something-went-wrong) in my code. Please help!..

## Replies

### Reply by Pravesh Singh

Hi Samuel,

In my WPF application I have ... System.Windows.Forms.Timer timer;

That is the wrong type of timer. Use a DispatcherTimer instead.

When i execute my program progressbar shows the [progress](https://yourviews.mindstick.com/view/284/devotees-arrived-in-prayagraj-while-work-is-still-in-progress) for two-three bars and then it stops

This surprises me, I wouldn't have expected it to work at all. This means you may have oher problems too, like blocking the main (dispatcher) thread.

You are only setting the Value once, in the Loaded event:

progressBar1.Value = DateTime.Now.Second;

There is no change to progressBar1.Value in the Tick event. So it figures that it stops moving.


---

Original Source: https://www.mindstick.com/forum/1521/wpf-progressbar

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
