- How can I block main UI Thread by MessageBox.Show("test") ?
- How can I change text my label from executed code by Quartz?
txtLabel.Text = "new value"; <= this not working because txtLabel don't exists on this class.
using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using Quartz;
namespace EMoreauDemoQuartzCS
{
[DisallowConcurrentExecution]
public class JobWriteToTextFile : IJob
{
public static Thread t;
public void run()
{
MessageBox.Show("test");
txtLabel.Text = "new value";
}
public Task Execute(IJobExecutionContext context)
{
t = new Thread(run);
t.SetApartmentState(ApartmentState.STA);
t.Start();
t.Join();
return Task.CompletedTask;
}
}
}