我在 WinForm 上有这段代码:
private void buttonStart_Click(object sender, EventArgs e)
{
Task.Factory.StartNew(() => ThreadFunction())
.ContinueWith(t => ThreadFunctionComplete()
, CancellationToken.None
, TaskContinuationOptions.None
, TaskScheduler.FromCurrentSynchronizationContext());
ThreadFinished();
}
我ThreadFinished()
只想在ThreadFunctionComplete()
完成后开始。好吧,我可以放在ThreadFinished()
末尾ThreadFunctionComplete()
,但是对于流程的某些工作流程,我不会。可能吗?也许是一种等待/锁定?