本文整理汇总了C#中Quartz.Core.QuartzScheduler.AddNoGCObject方法的典型用法代码示例。如果您正苦于以下问题:C# QuartzScheduler.AddNoGCObject方法的具体用法?C# QuartzScheduler.AddNoGCObject怎么用?C# QuartzScheduler.AddNoGCObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Quartz.Core.QuartzScheduler
的用法示例。
在下文中一共展示了QuartzScheduler.AddNoGCObject方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateScheduler
/// <summary>
/// Creates a scheduler using the specified thread pool and job store and
/// binds it for remote access.
/// </summary>
/// <param name="schedulerName">The name for the scheduler.</param>
/// <param name="schedulerInstanceId">The instance ID for the scheduler.</param>
/// <param name="threadPool">The thread pool for executing jobs</param>
/// <param name="threadExecutor">Thread executor.</param>
/// <param name="jobStore">The type of job store</param>
/// <param name="schedulerPluginMap"></param>
/// <param name="idleWaitTime">The idle wait time. You can specify TimeSpan.Zero for
/// the default value, which is currently 30000 ms.</param>
/// <param name="dbFailureRetryInterval">The db failure retry interval.</param>
/// <param name="maxBatchSize">The maximum batch size of triggers, when acquiring them</param>
/// <param name="batchTimeWindow">The time window for which it is allowed to "pre-acquire" triggers to fire</param>
public virtual void CreateScheduler(string schedulerName, string schedulerInstanceId, IThreadPool threadPool, IThreadExecutor threadExecutor,
IJobStore jobStore, IDictionary<string, ISchedulerPlugin> schedulerPluginMap, TimeSpan idleWaitTime,
TimeSpan dbFailureRetryInterval, int maxBatchSize, TimeSpan batchTimeWindow)
{
// Currently only one run-shell factory is available...
IJobRunShellFactory jrsf = new StdJobRunShellFactory();
// Fire everything u
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
threadPool.Initialize();
QuartzSchedulerResources qrs = new QuartzSchedulerResources();
qrs.Name = schedulerName;
qrs.InstanceId = schedulerInstanceId;
SchedulerDetailsSetter.SetDetails(threadPool, schedulerName, schedulerInstanceId);
qrs.JobRunShellFactory = jrsf;
qrs.ThreadPool = threadPool;
qrs.ThreadExecutor= threadExecutor;
qrs.JobStore = jobStore;
qrs.MaxBatchSize = maxBatchSize;
qrs.BatchTimeWindow = batchTimeWindow;
// add plugins
if (schedulerPluginMap != null)
{
foreach (ISchedulerPlugin plugin in schedulerPluginMap.Values)
{
qrs.AddSchedulerPlugin(plugin);
}
}
QuartzScheduler qs = new QuartzScheduler(qrs, idleWaitTime, dbFailureRetryInterval);
ITypeLoadHelper cch = new SimpleTypeLoadHelper();
cch.Initialize();
SchedulerDetailsSetter.SetDetails(jobStore, schedulerName, schedulerInstanceId);
jobStore.Initialize(cch, qs.SchedulerSignaler);
IScheduler scheduler = new StdScheduler(qs);
jrsf.Initialize(scheduler);
qs.Initialize();
// Initialize plugins now that we have a Scheduler instance.
if (schedulerPluginMap != null)
{
foreach (var pluginEntry in schedulerPluginMap)
{
pluginEntry.Value.Initialize(pluginEntry.Key, scheduler);
}
}
Log.Info(string.Format(CultureInfo.InvariantCulture, "Quartz scheduler '{0}", scheduler.SchedulerName));
Log.Info(string.Format(CultureInfo.InvariantCulture, "Quartz scheduler version: {0}", qs.Version));
SchedulerRepository schedRep = SchedulerRepository.Instance;
qs.AddNoGCObject(schedRep); // prevents the repository from being
// garbage collected
schedRep.Bind(scheduler);
initialized = true;
}
示例2: Instantiate
//.........这里部分代码省略.........
catch (Exception e)
{
Log.Error("Couldn't generate instance Id!", e);
throw new SystemException("Cannot run without an instance id.");
}
}
if (js is JobStoreSupport)
{
JobStoreSupport jjs = (JobStoreSupport) js;
jjs.InstanceId = schedInstId;
jjs.DbRetryInterval = dbFailureRetry;
}
QuartzSchedulerResources rsrcs = new QuartzSchedulerResources();
rsrcs.Name = schedName;
rsrcs.ThreadName = threadName;
rsrcs.InstanceId = schedInstId;
rsrcs.JobRunShellFactory = jrsf;
rsrcs.MakeSchedulerThreadDaemon = makeSchedulerThreadDaemon;
rsrcs.ThreadPool = tp;
rsrcs.SchedulerExporter = exporter;
if (tp is SimpleThreadPool)
{
((SimpleThreadPool) tp).ThreadNamePrefix = schedName + "_Worker";
}
tp.Initialize();
rsrcs.JobStore = js;
// add plugins
for (int i = 0; i < plugins.Length; i++)
{
rsrcs.AddSchedulerPlugin(plugins[i]);
}
schedCtxt = new SchedulingContext();
schedCtxt.InstanceId = rsrcs.InstanceId;
qs = new QuartzScheduler(rsrcs, schedCtxt, idleWaitTime, dbFailureRetry);
// Create Scheduler ref...
IScheduler sched = Instantiate(rsrcs, qs);
// set job factory if specified
if (jobFactory != null)
{
qs.JobFactory = jobFactory;
}
// Initialize plugins now that we have a Scheduler instance.
for (int i = 0; i < plugins.Length; i++)
{
plugins[i].Initialize(pluginNames[i], sched);
}
// add listeners
for (int i = 0; i < jobListeners.Length; i++)
{
qs.AddGlobalJobListener(jobListeners[i]);
}
for (int i = 0; i < triggerListeners.Length; i++)
{
qs.AddGlobalTriggerListener(triggerListeners[i]);
}
// set scheduler context data...
IEnumerator itr = new HashSet(schedCtxtProps).GetEnumerator();
while (itr.MoveNext())
{
string key = (String) itr.Current;
string val = schedCtxtProps.Get(key);
sched.Context.Put(key, val);
}
// fire up job store, and runshell factory
js.Initialize(loadHelper, qs.SchedulerSignaler);
jrsf.Initialize(sched, schedCtxt);
Log.Info(string.Format(CultureInfo.InvariantCulture, "Quartz scheduler '{0}' initialized", sched.SchedulerName));
Log.Info(string.Format(CultureInfo.InvariantCulture, "Quartz scheduler version: {0}", qs.Version));
// prevents the repository from being garbage collected
qs.AddNoGCObject(schedRep);
// prevents the db manager from being garbage collected
if (dbMgr != null)
{
qs.AddNoGCObject(dbMgr);
}
schedRep.Bind(sched);
return sched;
}
示例3: Instantiate
//.........这里部分代码省略.........
{
((SimpleThreadPool) tp).ThreadNamePrefix = schedName + "_Worker";
}
tp.Initialize();
tpInited = true;
rsrcs.JobStore = js;
// add plugins
for (int i = 0; i < plugins.Length; i++)
{
rsrcs.AddSchedulerPlugin(plugins[i]);
}
qs = new QuartzScheduler(rsrcs, idleWaitTime, dbFailureRetry);
qsInited = true;
// Create Scheduler ref...
IScheduler sched = Instantiate(rsrcs, qs);
// set job factory if specified
if (jobFactory != null)
{
qs.JobFactory = jobFactory;
}
// Initialize plugins now that we have a Scheduler instance.
for (int i = 0; i < plugins.Length; i++)
{
plugins[i].Initialize(pluginNames[i], sched);
}
// add listeners
for (int i = 0; i < jobListeners.Length; i++)
{
qs.ListenerManager.AddJobListener(jobListeners[i], EverythingMatcher<JobKey>.AllJobs());
}
for (int i = 0; i < triggerListeners.Length; i++)
{
qs.ListenerManager.AddTriggerListener(triggerListeners[i], EverythingMatcher<TriggerKey>.AllTriggers());
}
// set scheduler context data...
foreach (string key in schedCtxtProps)
{
string val = schedCtxtProps.Get(key);
sched.Context.Put(key, val);
}
// fire up job store, and runshell factory
js.InstanceId = schedInstId;
js.InstanceName = schedName;
js.ThreadPoolSize = tp.PoolSize;
js.Initialize(loadHelper, qs.SchedulerSignaler);
jrsf.Initialize(sched);
qs.Initialize();
Log.Info("Quartz scheduler '{0}' initialized".FormatInvariant(sched.SchedulerName));
Log.Info("Quartz scheduler version: {0}".FormatInvariant(qs.Version));
// prevents the repository from being garbage collected
qs.AddNoGCObject(schedRep);
// prevents the db manager from being garbage collected
if (dbMgr != null)
{
qs.AddNoGCObject(dbMgr);
}
schedRep.Bind(sched);
return sched;
}
catch (SchedulerException)
{
if (qsInited)
{
qs.Shutdown(false);
}
else if (tpInited)
{
tp.Shutdown(false);
}
throw;
}
catch
{
if (qsInited)
{
qs.Shutdown(false);
}
else if (tpInited)
{
tp.Shutdown(false);
}
throw;
}
}
示例4: CreateScheduler
/// <summary>
/// Creates a scheduler using the specified thread pool and job store and
/// binds it to RMI.
/// </summary>
/// <param name="schedulerName">The name for the scheduler.</param>
/// <param name="schedulerInstanceId">The instance ID for the scheduler.</param>
/// <param name="threadPool">The thread pool for executing jobs</param>
/// <param name="jobStore">The type of job store</param>
/// <param name="schedulerPluginMap"></param>
/// <param name="idleWaitTime">The idle wait time. You can specify TimeSpan.Zero for
/// the default value, which is currently 30000 ms.</param>
/// <param name="dbFailureRetryInterval">The db failure retry interval.</param>
public virtual void CreateScheduler(string schedulerName, string schedulerInstanceId, IThreadPool threadPool,
IJobStore jobStore, IDictionary schedulerPluginMap, TimeSpan idleWaitTime,
TimeSpan dbFailureRetryInterval)
{
// Currently only one run-shell factory is available...
IJobRunShellFactory jrsf = new StdJobRunShellFactory();
// Fire everything up
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SchedulingContext schedCtxt = new SchedulingContext();
schedCtxt.InstanceId = schedulerInstanceId;
QuartzSchedulerResources qrs = new QuartzSchedulerResources();
qrs.Name = schedulerName;
qrs.InstanceId = schedulerInstanceId;
qrs.JobRunShellFactory = jrsf;
qrs.ThreadPool = threadPool;
qrs.JobStore = jobStore;
// add plugins
if (schedulerPluginMap != null)
{
foreach (ISchedulerPlugin plugin in schedulerPluginMap.Values)
{
qrs.AddSchedulerPlugin(plugin);
}
}
QuartzScheduler qs = new QuartzScheduler(qrs, schedCtxt, idleWaitTime, dbFailureRetryInterval);
ITypeLoadHelper cch = new CascadingClassLoadHelper();
cch.Initialize();
jobStore.Initialize(cch, qs.SchedulerSignaler);
IScheduler scheduler = new StdScheduler(qs, schedCtxt);
// Initialize plugins now that we have a Scheduler instance.
if (schedulerPluginMap != null)
{
foreach (DictionaryEntry pluginEntry in schedulerPluginMap)
{
((ISchedulerPlugin)pluginEntry.Value).Initialize(
(string) pluginEntry.Key, scheduler);
}
}
jrsf.Initialize(scheduler, schedCtxt);
Log.Info(string.Format(CultureInfo.InvariantCulture, "Quartz scheduler '{0}", scheduler.SchedulerName));
Log.Info(string.Format(CultureInfo.InvariantCulture, "Quartz scheduler version: {0}", qs.Version));
SchedulerRepository schedRep = SchedulerRepository.Instance;
qs.AddNoGCObject(schedRep); // prevents the repository from being
// garbage collected
schedRep.Bind(scheduler);
}