private void OnClick(object sender, EventArgs e)
        {
            var button = NotifyIcon.ContextMenu.MenuItems[0];

            if (button.Text == "중지")
            {
                RunningChanged?.Invoke(this, null);
                button.Text = "시작";
            }
            else
            {
                BackgroundTask BackgroundTask = new BackgroundTask();
                RunningChanged += delegate { BackgroundTask.Stop(); };
                BackgroundTask.Start();
                button.Text = "중지";
            }
        }
예제 #2
0
        public static void Stop()
        {
            foreach (CancellationTokenSource token in _activeTasks)
            {
                token.Cancel();
            }
            if (_currentEngine != null)
            {
                _currentEngine.KillChildrenThreads();
            }
            Reset();
            _context.IsRunning = false;
            RunningChanged?.Invoke(null, new EventArgs());

            OnStep       = null;
            OnRenderStep = null;
            _runtimeKeybinds.Clear();
        }
예제 #3
0
        public static void Run()
        {
            _activeTasks.Clear();
            _context.IsRunning = true;
            RunningChanged?.Invoke(null, new EventArgs());
            Save();
            //Output.Out.AddLine("Saved cached copy of current state: " + _savedState.Length);
            _currentEngine = new EngineJS();
            List <Task> scriptExecution = new List <Task>();

            foreach (Script script in _context.ActiveWorld.World.getChildren(true).Where((x) =>
            {
                return(x.GetType().Equals(typeof(Script)));
            }))
            {
                CancellationTokenSource token = new CancellationTokenSource();
                scriptExecution.Add(new Task((x) =>
                {
                    Thread currentThread = Thread.CurrentThread;
                    using (token.Token.Register(currentThread.Abort))
                    {
                        _currentEngine.Execute(x as Script);
                    }
                }, script, token.Token));
                _activeTasks.Add(token);
            }

            foreach (Task execution in scriptExecution)
            {
                execution.Start();
            }

            Thread mainLoop = new Thread(MainLoop);

            mainLoop.Start();
        }
예제 #4
0
파일: TimeBar.cs 프로젝트: leeyi45/acmun
 private void Internal_RunningChanged(object sender, EventArgs e)
 => RunningChanged?.Invoke(this, EventArgs.Empty);