예제 #1
0
        /// <summary>
        /// Returns a handle to the Scheduler produced by this factory.
        /// </summary>
        /// <remarks>
        /// If one of the <see cref="Initialize()" /> methods has not be previously
        /// called, then the default (no-arg) <see cref="Initialize()" /> method
        /// will be called by this method.
        /// </remarks>
        public virtual IScheduler GetScheduler()
        {
            Log.Error("GetSchedulerstars");
            if (cfg == null)
            {
                Initialize();
            }

            SchedulerRepository schedRep = SchedulerRepository.Instance;

            IScheduler sched = schedRep.Lookup(SchedulerName);

            if (sched != null)
            {
                if (sched.IsShutdown)
                {
                    schedRep.Remove(SchedulerName);
                }
                else
                {
                    return(sched);
                }
            }
            sched = Instantiate();

            return(sched);
        }
예제 #2
0
        /// <summary>
        /// Returns a handle to the Scheduler produced by this factory.
        /// </summary>
        /// <remarks>
        /// If one of the <see cref="Initialize()" /> methods has not be previously
        /// called, then the default (no-arg) <see cref="Initialize()" /> method
        /// will be called by this method.
        /// </remarks>
        public virtual async Task <IScheduler> GetScheduler(CancellationToken cancellationToken = default)
        {
            if (cfg == null)
            {
                Initialize();
            }

            SchedulerRepository schedRep = SchedulerRepository.Instance;

            IScheduler?sched = await schedRep.Lookup(SchedulerName, cancellationToken).ConfigureAwait(false);

            if (sched != null)
            {
                if (sched.IsShutdown)
                {
                    schedRep.Remove(SchedulerName);
                }
                else
                {
                    return(sched);
                }
            }

            sched = await Instantiate().ConfigureAwait(false);

            return(sched !);
        }