程序源码为:
private void Btn_OutPut_Click(object sender, EventArgs e)
{
List<Fruit> p_Fruit = new List<Fruit>();
foreach(DataGridViewRow dgvr in dgv_Message.Rows)
{
p_Fruit.Add(new Fruit()
{
Name = dgvr.Cells[0].Value.ToString(),
Price = Convert.ToSingle(dgvr.Cells[1].Value.ToString())
});
}
SaveFileDialog P_SaveFileDialog = new SaveFileDialog();
P_SaveFileDialog.Filter = "*.xls|*.xls";
if(DialogResult.OK==P_SaveFileDialog.ShowDialog())
{
ThreadPool.QueueUserWorkItem(
(pp) =>
{
G_ea = new Microsoft.Office.Interop.Excel.Application();
Excel.Workbook P_wk = G_ea.Workbooks.Add(G_missing);
Excel.Worksheet P_ws = (Excel.Worksheet)P_wk.Worksheets.Add(
G_missing, G_missing, G_missing, G_missing);
for(int i=0;i<p_Fruit.Count;i++)
{
P_ws.Cells[i + 1, 1] = p_Fruit[i].Name;
P_ws.Cells[i + 1, 2] = p_Fruit[i].Price.ToString();
}
P_wk.SaveAs(P_SaveFileDialog.FileName, G_missing, G_missing, G_missing,
G_missing, G_missing, Excel.XlSaveAsAccessMode.xlShared, G_missing,
G_missing, G_missing, G_missing, G_missing);
((Excel._Application)G_ea.Application).Quit();
this.Invoke((MethodInvoker)(() =>
{
MessageBox.Show("成功创建Excel文档!", "提示");
}));
});
}
}
这段代码怎么知道线程池中创建Excel 文档是否成功?