源码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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 WpfApplication1
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
BackgroundWorker bgWork = new BackgroundWorker();//后台线程
public MainWindow()
{
InitializeComponent();
bgWork.WorkerReportsProgress = true;//报告进度更新
bgWork.WorkerSupportsCancellation = true;//支持异步取消
bgWork.DoWork += DoWork_Handler;
bgWork.ProgressChanged += ProgressCha