如何在单线程单元中将“ FluentScheduler”与ActiveX控件一起使用?
此刻我出现以下错误:
ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated
because the current thread is not in a single-threaded apartment.
[STAThread]无法使用:
static class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
}
public class ScheduledJobRegistry : Registry
{
public ScheduledJobRegistry()
{
Schedule<MyJob>()
.NonReentrant() // Only one instance of the job can run at a time
.ToRunOnceAt(DateTime.Now.AddSeconds(1)) // Delay startup for a while
.AndEvery(15).Seconds(); // Interval
}
}
public class MyJob : IJob
{
public void Execute()
{
// Execute your scheduled task here
GetAndPrintTickets(); <- here is ActiveX Control
}
}
}