您好我是新手赢得Form,我想在表单上的文本框中显示以下任务的进度,但我无法这样做。
// Create progress printing and querying tasks
Task progressPrintTask = new Task(() =>
{
IJob jobQuery = null;
do
{
var progressContext = new CloudMediaContext(_accountName, _accountKey);
jobQuery = progressContext.Jobs.Where(j => j.Id == job.Id).First();
// AppendTextBox("Indexer Job started");
// textBox2.AppendText(string.Format("{0}\t{1}\t{2}", DateTime.Now, jobQuery.State, jobQuery.Tasks[0].Progress));
// Console.WriteLine(string.Format("{0}\t{1}\t{2}", DateTime.Now, jobQuery.State, jobQuery.Tasks[0].Progress));
Thread.Sleep(10000);
}
while (jobQuery.State != JobState.Finished &&
jobQuery.State != JobState.Error &&
jobQuery.State != JobState.Canceled);
});
progressPrintTask.Start();
请检查屏幕截图更多细节
请帮忙
答案 0 :(得分:0)
我猜你错过了一个调用:
// Create progress printing and querying tasks
Task progressPrintTask = new Task(() =>
{
IJob jobQuery = null;
do
{
var progressContext = new CloudMediaContext(_accountName, _accountKey);
jobQuery = progressContext.Jobs.Where(j => j.Id == job.Id).First();
textBox2.Invoke(() => textBox2.AppendText(string.Format("{0}\t{1}\t{2}", DateTime.Now, jobQuery.State, jobQuery.Tasks[0].Progress)));
Thread.Sleep(10000);
}
while (jobQuery.State != JobState.Finished &&
jobQuery.State != JobState.Error &&
jobQuery.State != JobState.Canceled);
});
progressPrintTask.Start();