Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- using System.ComponentModel;
- using System.Threading;
- namespace WpfApp1
- {
- /// <summary>
- /// Interaction logic for MainWindow.xaml
- /// </summary>
- public partial class MainWindow : Window, INotifyPropertyChanged
- {
- private BackgroundWorker _bgWorker = new BackgroundWorker();
- private int _workerState;
- public int WorkerState
- {
- get { return _workerState; }
- set
- {
- _workerState = value;
- if (PropertyChanged != null)
- PropertyChanged(this, new PropertyChangedEventArgs("WorkerState"));
- }
- }
- public MainWindow()
- {
- InitializeComponent();
- DataContext = this;
- _bgWorker.DoWork += (s, e) =>
- {
- for (int i = 0; i <= 10; i++)
- {
- Thread.Sleep(1000);
- WorkerState = i;
- }
- };
- _bgWorker.RunWorkerAsync();
- }
- public event PropertyChangedEventHandler PropertyChanged;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement