如何在显示ProgressBar的同时执行方法,然后显示Form?如何在显示ProgressBar时执行方法,然后在显示Form后执行?
private void btnCienciaEmissao_Click(object sender, EventArgs e)
{
var progressForm = new ProgressBar.frmPBText();
var retornoManifestacao = new frmConsultaNotaEmitidaContraCNPJAntigoRetornoManifestacao();
var threadProcesso = new Thread(() =>
{
Parametros.DgvRetornoManifestacao = ExecutaManifestacao();
progressForm.BeginInvoke(new Action(() => { progressForm.Close(); }));
retornoManifestacao.BeginInvoke(new Action(() => { retornoManifestacao.dgvRetornoManifestacaoDataSource(Parametros.DgvRetornoManifestacao);}));
});
threadProcesso.Start();
progressForm.Show();
// I WANT TO SHOW RetornoManifestacao ONLY AFTER threadProcesso FINISHED
retornoManifestacao.Show();
}
我希望表单retornoManifestacao
显示threadProcesso
结束后。
如果我使用retornoManifestacao.Show()
,就像上面那样,表格会出现在threadProcesso
之前。我需要它在Thread结束后才出现。
我尝试使用threadProcesso.Join()
,但progressForm
冻结。
我的progressForm
有一个选取框样式ProgressBar
,所以没有必要报告进度。
其实很容易做到..perhaps你应该做一个谷歌搜索如何创建一个启动画面和或显示一个窗体前显示一个进度栏.. – MethodMan 2015-02-09 20:52:01
这将有助于看到更多的细节 - 确切地说,你被困住,哪部分你需要帮助,什么错误你会得到(如果有的话)。 – 2015-02-09 21:06:04
@GrantWinney如果我使用RetornoManifestacao.Show(),就像上面那样,表单会在threadProcesso结束之前出现。我需要它在Thread结束后才出现。 – 2015-02-09 21:43:07