private void ShowExecute(Product product) { FormExecute formExecute = new FormExecute { Product = product }; formExecute.ShowDialog(); }
private void btnUploadProduct_Click(object sender, EventArgs e) { this.btnUpload.Text = "正在上传中..."; this.btnUpload.Enabled = false; //foreach (Product product in Products) //{ // this.ShowExecute(product); //} foreach (Product product in Products) { FormExecute formExecute = new FormExecute { Product = product }; formExecute.ShowDialog(); Thread.Sleep(1000 * 1); } Task.Factory.StartNew(() => { bool singal = true; while (singal) { if (CheckWhetherAllProductsUploaded(Products) == true) { StringBuilder builder = new StringBuilder(); foreach (Product product in Products) { builder.AppendLine("Username: "******", Product: " + product.Name + ", Result: " + product.UploadResult + "\r\n"); } FormDoneInfo.UploadResultMessage = builder.ToString(); MethodInvoker mi = new MethodInvoker(this.ShowResult); this.BeginInvoke(mi); singal = false; //this.Hide(); } else { Thread.Sleep(1000 * 10); } } }); }