Esempio n. 1
0
        protected virtual void OnEngineStarted()
        {
            FullyQualifiedName = GetType().FullName;
            Version            = AssemblyName.GetAssemblyName(Assembly.GetExecutingAssembly().Location).Version.ToString();

            StartTime = DateTimeOffset.Now;
            State     = EngineState.Normal;

            Logger.Info("The scheduler engine has started.");
            Logger.Info($"  Scheduler Type: {FullyQualifiedName}, Version: {Version}");

            EngineStarted?.Invoke(this, new EngineOperationEventArgs {
                State = State
            });
        }
Esempio n. 2
0
 internal static void NotifyEngineStarted(SchubertOptions options, IServiceProvider builder)
 {
     if (EngineStarted != null)
     {
         EngineStarted(options, builder);
         if (EngineStarted != null) //再次判断,因为可能在执行方法中使用 “-=” 操作手动移除事件订阅使得委托链再次为空。
         {
             //清除委托列表,防止资源无法被 GC 收集。
             foreach (var delegateItem in EngineStarted.GetInvocationList())
             {
                 EngineStarted -= (EngineStartedHandler)delegateItem;
             }
         }
     }
 }
Esempio n. 3
0
        private static void RunEngineStartedTimer()
        {
            if (engineStartedTimer != null)
            {
                engineStartedTimer.Dispose();
                engineStartedTimer = null;
            }

            engineStartedTimer = new Timer(delegate
            {
                if (CurrentIgnitionState == IgnitionState.Ign &&
                    CurrentRPM > 0 &&
                    EngineStarted != null)
                {
                    EngineStarted.Invoke();
                }
            }, null, 2000, 0);
        }
 private void OnCarStarted()
 {
     EngineStarted?.Invoke(this);
 }
 public void Start()
 {
     IsRunning = true;
     EngineStarted?.Invoke(this, EventArgs.Empty);
 }