title: wpf progressbar doesn't update on last ProgressChanged
body: <p>I making some UI and I have ProgressBar in it. Using MVVM pattern.</p>
  
  <p>XAML:</p>
  
  <pre><code>&lt;ProgressBar Grid.Row="2" Minimum="0" Maximum="100" Value="{Binding CurrentProgress, Mode=OneWay}"/&gt;
  </code></pre>
  
  <p>ViewModel (simplified):    </p>
  
  <pre><code>class MyClass : ViewModelBase
  {
      /// &lt;summary&gt;
      /// Fields
      /// &lt;/summary&gt;
      private int _currentProgress;
      private readonly BackgroundWorker _worker;
      private int _step; 
  
      /// &lt;summary&gt;
      /// Properties
      /// &lt;/summary&gt;
      public int CurrentProgress
      {
          get
          {
              return _currentProgress;
          }
          set
          {
              if (_currentProgress != value)
              {
                  _currentProgress = value;
                  RaisePropertyChanged("CurrentProgress");
              }
          }
      }
  
      /// &lt;summary&gt;
      /// Constructor
      /// &lt;/summary&gt;
      public MyClass()
      {
          _step = 10;
          _currentProgress = 0;
          _worker = new BackgroundWorker();
          _worker.DoWork += DoWork;
          _worker.WorkerReportsProgress = true;
          _worker.ProgressChanged += ProgressChanged;
          _worker.RunWorkerCompleted += RunWorkerCompleted;
      }
  
      /// &lt;summary&gt;
      /// Command 
      /// &lt;/summary&gt;
      private RelayCommand _myCommand;
      public RelayCommand MyCommand
      {
          get
          {
              return _myCommand ?? (_myCommand =
                  new RelayCommand(_worker.RunWorkerAsync, CanMyCommand));
          }
      }
  
      private bool CanMyCommand()
      {
          return true;
      }
  
      /// &lt;summary&gt;
      /// Handlers
      /// &lt;/summary&gt;
      /// &lt;param name="sender"&gt;&lt;/param&gt;
      /// &lt;param name="e"&gt;&lt;/param&gt;
      private void DoWork(object sender, DoWorkEventArgs e)
      {
          for (int i = 0; i &lt; 10; i++)
              ConsumingMethod();
      }
  
      private void RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
      {
          Thread.Sleep(5000);
          Messenger.Default.Send(new CloseAddDocumentWindow(String.Empty));
      }
  
      private void ProgressChanged(object sender, ProgressChangedEventArgs e)
      {
          CurrentProgress = e.ProgressPercentage;
      }
  
      /// &lt;summary&gt;
      /// Method
      /// &lt;/summary&gt;
      private void ConsumingMethod()
      {
          CurrentProgress += _step;
      }
  }
  </code></pre>
  
  <p>Code-Behind:</p>
  
  <pre><code> Messenger.Default.Register&lt;CloseAddDocumentWindow&gt;(this, nm =&gt;
   {
        if (nm.Sender == DataContext)
            Close();
   });
  </code></pre>
  
  <p>So, this</p>
  
  <pre><code> Messenger.Default.Send(new CloseAddDocumentWindow(String.Empty));
  </code></pre>
  
  <p>is the problem. That line close window as u see. If I comment that line, progressbar works good. 10, 20, 30, ... 100% I see. But else, progressbar looks like 10, 20, 30, ... 90%, some waiting and window closing! I try to use Thread.Sleep(5000), to give the progressbar some time to drawing. But even that doesn't help. So, how can I see last persentage change if window closing immediately after that?</p>