本文整理汇总了C#中Scheduler.SubmitJob方法的典型用法代码示例。如果您正苦于以下问题:C# Scheduler.SubmitJob方法的具体用法?C# Scheduler.SubmitJob怎么用?C# Scheduler.SubmitJob使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scheduler
的用法示例。
在下文中一共展示了Scheduler.SubmitJob方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Register
public static void Register(HttpConfiguration config)
{
Scheduler = new Scheduler();
TmxGasJob = new Job();
ForexJob = new Job();
MyWeatherJob = new Job();
PlantStatusJob = new Job();
TmxGasJob.Run.From(DateTime.Now).Every.Hours(1);
ForexJob.Run.From(DateTime.Now).Every.Hours(1);
MyWeatherJob.Run.From(DateTime.Now).Every.Days(1);
PlantStatusJob.Run.From(DateTime.Now).Every.Minutes(5);
TmxGasJob.Pause();
ForexJob.Pause();
MyWeatherJob.Pause();
PlantStatusJob.Pause();
Scheduler.SubmitJob(TmxGasJob, p => GasIndexDownloader.Process());
Scheduler.SubmitJob(ForexJob, p => ForexDownloader.Process());
Scheduler.SubmitJob(TmxGasJob, p => MyWeatherDownloader.Process());
Scheduler.SubmitJob(PlantStatusJob, p => PlantStatusDownloader.Process());
var context = new TBSPEntities1();
IQueryable<AppSetting> backgroundEnabled = (context.AppSettings.Where(
appSetting => appSetting.Description == "BackgroundQueueEnabled")
).Take(1);
if (!backgroundEnabled.Any()) throw new Exception("Unable to find background queue config");
if (!backgroundEnabled.First().Value.ToUpper().Equals("TRUE"))
{
TBSPLogger.Info("SchedulerConfig", "Skipping Background Jobs");
}
else
{
TBSPLogger.Info("SchedulerConfig", "Starting Background Jobs");
TmxGasJob.Resume();
ForexJob.Resume();
MyWeatherJob.Resume();
PlantStatusJob.Resume();
}
}
示例2: ScheduleJob
private static void ScheduleJob(Scheduler scheduler, ISchedulerJob job) {
var outWin = (IVsOutputWindow)HpcSupportPackage.GetGlobalService(typeof(IVsOutputWindow));
IVsOutputWindowPane pane;
if (ErrorHandler.Succeeded(outWin.GetPane(VSConstants.GUID_OutWindowGeneralPane, out pane))) {
pane.Activate();
pane.OutputString("Submitting job " + job.Id + Environment.NewLine);
}
var shell = (IVsUIShell)HpcSupportPackage.GetGlobalService(typeof(SVsUIShell));
IntPtr owner;
if (ErrorHandler.Succeeded(shell.GetDialogOwnerHwnd(out owner))) {
scheduler.SetInterfaceMode(false, owner);
}
ThreadPool.QueueUserWorkItem(x => {
try {
scheduler.SubmitJob(job, null, null);
} catch (Exception ex) {
string msg;
msg = "Failed to submit job " + ex.ToString();
if (pane != null) {
pane.OutputString(msg);
} else {
MessageBox.Show(msg, "Python Tools for Visual Studio");
}
}
});
}