先来一个加载窗体代码
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
1 public partial class FrmLoading : Form 2 { 3 public BackgroundWorker updateDBWorker=new BackgroundWorker(); 4 5 public Action BackgroundWorkAction 6 { 7 get; 8 set; 9 } 10 11 public KeyValuePair<int, string> CurrentMsg 12 { 13 set 14 { 15 this.updateDBWorker.ReportProgress(value.Key, value.Value); 16 } 17 } 18 19 public FrmLoading() 20 { 21 InitializeComponent(); 22 this.updateDBWorker.WorkerReportsProgress = true; 23 this.updateDBWorker.WorkerSupportsCancellation = true; 24