これは私のコードです:
private void TaskGestioneCartelle()
{
Task.Factory.StartNew(() => GeneraListaCartelle())
.ContinueWith(t => GeneraListaCartelleCompletata()
, CancellationToken.None
, TaskContinuationOptions.None
, TaskScheduler.FromCurrentSynchronizationContext());
}
private void GeneraListaCartelle()
{
// ... code
}
private void GeneraListaCartelleCompletata()
{
Task.Factory.StartNew(() => CopiaCartelle())
.ContinueWith(t => CopiaCartelleCompletato()
, CancellationToken.None
, TaskContinuationOptions.None
, TaskScheduler.FromCurrentSynchronizationContext());
}
private void CopiaCartelle()
{
if (txtLog.InvokeRequired)
{
txtLog.BeginInvoke(new MethodInvoker(delegate { txtLog.AppendText("Copio cartelle in corso..." + Environment.NewLine); }));
}
}
スレッドを開始します。終了したら、(Continue with から) 別のスレッドを開始し、UI の Control に何かを書き込もうとします。しかし、実際には何も書かれていませんtxtLog
。どこが間違っていますか?