C# 使用Task.Factory更新流程内的标签

C# 使用Task.Factory更新流程内的标签,c#,C#,我有一个由以下方式的表单触发的流程: public partial class LoadingDialog : Form { public Action Worker { set; get; } public LoadingDialog(Action worker) { InitializeComponent(); if (worker == null) throw new ArgumentNullException();

我有一个由以下方式的表单触发的流程:

public partial class LoadingDialog : Form
{
    public Action Worker { set; get; }
    public LoadingDialog(Action worker)
    {
        InitializeComponent();
        if (worker == null) throw new ArgumentNullException();

        Worker = worker;
    }

    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        Task.Factory
           .StartNew(Worker)
           .ContinueWith(t => 
           { 
              this.Close(); 
           }, TaskScheduler.FromCurrentSynchronizationContext());
    }
}
可以看出,
LoadingDialog
只是一个带有标签和进度条的小对话框

嗯,标签需要根据流程的状态进行更新

我不知道如何在流程(
Worker
)中更新
加载对话框中的标签

有什么帮助吗

更新

using (LoadingDialog loadingDialog = new LoadingDialog(proceso.start_process))
            {
                loadingDialog.ShowDialog();
            }
如果我将该作为参数传递,它将显示一个错误,因为它采用主形式,而不是using语句中使用的加载对话框。

更改

Action Worker

动作工作者

使用参数“this”启动任务

我通过以下方式触发该方法:使用(LoadingDialog LoadingDialog=new LoadingDialog(proceso.Start_进程)){LoadingDialog.ShowDialog();}procesi.Start_进程是工作进程,因此,我无法放置this指针,因为它与using语句中使用的形式不同。
Action<object> Worker