可以新建一个函数
void setText(string str)
{
Action action = () =>
{
log.Content = str;
};
log.Dispatcher.BeginInvoke(action);
}
其中,str为要设置的文本,log为标签的名字,如果内容过多的话可以考虑用多线程运行这个程序
//启动线程处理
Thread thread1 = new Thread(setText);
thread1.IsBackground = true;//设置为后台线程,当主线程结束后,后台线程自动退出,否则不会退出程序不能结束
thread1.Start();
但是好像不能传参数,可以考虑把str换成全局变量