这可能是一个愚蠢的问题,但我在stackoverflow上找不到答案。
我在一个Winform应用程序中有一个按钮点击事件,该事件运行一个线程来计算结果以显示在窗体中。
当线程计算出结果时,如何更新窗体的UI?
private void btnRequestR2Approval_Click(object sender, EventArgs e)
{
if (User.IsLogged)
{
ValidationResults results = new ValidationResults();
results.Show();
Logger log = Logger.Instance();
Logger.NewLogAddedHandler messageDelegate = new Logger.NewLogAddedHandler(results.NewLogMessage);
if (!log.IsEventHandlerRegistered())
{
log.NewLogAdded += messageDelegate;
}
ThreadStart operation = new ThreadStart(ValidateAndSubmit);
Thread theThread = new Thread(operation);
theThread.Start();
}
else
{
MessageBox.Show("Please login");
}
}
谢谢你