public Course(bool createTimer) { this.years = new Year[3]; for (int i = 0; i < 3; i++) { this.years[i] = new Year(i + 1); this.years[i].Change += this.childChangedHandler; this.years[i]._WarningEmitted += this.warningEmittedHandler; this.years[i].TriggerCalculation(); } this.title = Properties.Resources.COURSE_DEFAULT_TITLE; this.Result = Course.Degree.Unknown; this.warnings = new CourseWarnings(); this.warnings.WarningsChanged += this.warningsChangedHandler; this._WarningEmitted += this.handleWarningChain; if (createTimer) { this.saveTimer = new Timer(Double.Parse(Properties.Resources.COURSE_SAVE_INTERVAL, CultureInfo.InvariantCulture)); this.saveTimer.AutoReset = true; this.saveTimer.Elapsed += (object sender, ElapsedEventArgs e) => { ConcurrentWorkQueue.Enqueue(() => { new CourseXMLBackend(this.DeepClone()).SetPath(Properties.Resources.SAVE_FILE_PATH).Save(); }); }; this.saveTimer.Start(); } }
public void populate() { this.view.Invoke((MethodInvoker) delegate { this.view.BeginLoading(); this.view.reset(); this.view.ModuleName = this.module.Title; this.view.ModuleCode = this.module.Code; this.view.ModuleCredits = this.module.Credits; this.view.ModuleResult = this.module.Result; }); ConcurrentWorkQueue.Enqueue(() => { foreach (var assessment in this.module.Assessments) { this.view.Invoke((MethodInvoker) delegate { Application.DoEvents(); this.view.createAssessment(this.openAssessmentHandler, this.removeAssessmentHandler, assessment); }); } this.view.Invoke((MethodInvoker) delegate { this.view.EndLoading(); }); }); }
public void LoadCourseHandler(object sender, EventArgs e) { OpenFileDialog file = new OpenFileDialog(); file.InitialDirectory = Environment.CurrentDirectory; file.CheckFileExists = true; file.CheckPathExists = true; file.Multiselect = false; file.ValidateNames = true; file.Filter = "Course files (*.course)|*.course"; file.FileOk += (s, ee) => { try { ConcurrentWorkQueue.Enqueue(() => { Course c = new CourseXMLBackend(null).SetPath(file.FileName).Load(); this.registerCourse(c); }); } catch (InvalidCourseXMLException) { MessageBox.Show("Error loading course, the file might be corrupted.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }; file.ShowDialog(); }
protected virtual void childChangedHandler(CourseObjectBase sender, bool triggerRecalculation) { this.onChange(false); if (triggerRecalculation) { ConcurrentWorkQueue.Enqueue(() => this.recalculateResult()); } }
public CoursePredictorApplication() { // Initialize concurrent job queue ConcurrentWorkQueue.Initialize(); // Start the application this.mainWindow = new GradePredictor.GUI.MainWindowController(); this.MainForm = this.mainWindow.View; this.MainForm.Show(); }
public void SaveCourseHandler(object sender, EventArgs e) { SaveFileDialog file = new SaveFileDialog(); file.InitialDirectory = Environment.CurrentDirectory; file.CheckPathExists = true; file.ValidateNames = true; file.Filter = "Course files (*.course)|*.course"; file.FileOk += (s, ee) => { ConcurrentWorkQueue.Enqueue(() => { new CourseXMLBackend(this.course.DeepClone()).SetPath(file.FileName).Save(); }); }; file.ShowDialog(); }
internal static void Start(object obj) { _queue = new ConcurrentWorkQueue <Action>(action => action()); Game.Init(); RunService.Init(); SocialService.Init(); HttpService.Init(); ScriptService.Init(); //AnalyticsService.Init(); _resetter.Set(); var stopwatch = Stopwatch.StartNew(); var physicsStopwatch = Stopwatch.StartNew(); while (!CancelTokenSource.IsCancellationRequested) { var step = stopwatch.Elapsed.TotalSeconds; stopwatch.Restart(); // User Input InputService.Step(); Game.FocusedCamera?.UpdateCamera(step); // Network Replication Game.NetworkServer?.Update(step); Game.NetworkClient?.Update(step); // wait() resume ScriptService.ResumeWaitingScripts(); // Stepped RunService.Update(step); _queue.Work(); // Physics var physicsStep = (float)physicsStopwatch.Elapsed.TotalSeconds; foreach (var world in Game.Worlds) { world.Key.Physics?.Step(physicsStep); } physicsStopwatch.Restart(); // Heartbeat RunService.Service.Heartbeat.Fire(step); } }
private void registerCourse(Course course) { if (course != null) { this.view.Invoke((MethodInvoker) delegate { this.view.reset(); this.view.startNew(); }); this.view.Invoke((MethodInvoker) delegate { this.warningsWindow.BeginLoading(); }); if (this.course != null) { this.course.Detach(); } this.course = course; this.course.Change += this.CourseChangedHandler; this.course.WarningEmitted += this.WarningsChangedHandler; this.course.TriggerCalculation(); ConcurrentWorkQueue.Enqueue(() => this.view.Invoke((MethodInvoker) delegate { this.warningsWindow.EndLoading(); })); this.view.Invoke((MethodInvoker) delegate { this.view.BeginLoading(); }); foreach (Year y in this.course.Years) { foreach (Module m in y.Modules) { this.view.Invoke((MethodInvoker) delegate { this.view.createModule(y.Number, this.OpenModuleHandler, this.RemoveModuleHandler, m); Application.DoEvents(); }); } } this.view.Invoke((MethodInvoker) delegate { this.view.SelectYearOne(); this.view.ResetModuleControlPositions(1); this.view.SelectYearTwo(); this.view.ResetModuleControlPositions(2); this.view.SelectYearThree(); this.view.ResetModuleControlPositions(3); this.view.SelectYearOne(); this.view.EndLoading(); }); } }
internal static void Init() { LoggerInternal = LogManager.GetLogger(nameof(ScriptService)); EnumTypes = typeof(Engine).Assembly.GetTypes().Where(x => x.IsEnum); CacheTypes(); Lua = new Lua(LuaIntegerType.Int32, LuaFloatType.Double); GlobalEnvironment = new ScriptGlobal(Lua); ExecutionQueue = new ConcurrentWorkQueue <Execution>(execution => { if (!execution.TryFulfill()) { ExecutionQueue.Enqueue(execution); // send to back of queue } else { execution.Set(); } }); }
internal static void Start(object obj) { _queue = new ConcurrentWorkQueue <Action>(action => action()); switch (RenderSettings.GraphicsMode) { case GraphicsMode.Direct3D11: Renderer.Init(); break; case GraphicsMode.NoGraphics: break; default: throw new ArgumentOutOfRangeException(nameof(RenderSettings.GraphicsMode), $"Unsupported graphics mode \"{RenderSettings.GraphicsMode}\""); } Logger.Info("Loading primitives..."); Primitives.Load(); Logger.Info("Primitives loaded."); if (RenderSettings.GraphicsMode == GraphicsMode.NoGraphics) { return; } _resetter.Set(); var _stopwatch = Stopwatch.StartNew(); Logger.Info("Entering render loop..."); while (!CancelTokenSource.IsCancellationRequested) { Renderer.Update(_stopwatch.Elapsed.TotalSeconds); _queue.Work(); _stopwatch.Restart(); } Renderer.Shutdown(); }
public void FileDroppedHandler(object sender, DragEventArgs e) { string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); IEnumerable <string> selection = files.Where((string s) => s.Contains(".course")); string x; if (selection.Count() > 0) { x = selection.First(); ConcurrentWorkQueue.Enqueue(() => { try { Course c = new CourseXMLBackend(null).SetPath(x).Load(); this.registerCourse(c); } catch (InvalidCourseXMLException) { MessageBox.Show("Error loading course, the file might be corrupted.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }); } }
internal static void Start(object obj) { _queue = new ConcurrentWorkQueue <Action>(action => action()); SoundService.Init(); XAudioDLL = Kernel32.LoadLibraryEx("XAudio2_7.DLL", IntPtr.Zero, (LoadLibraryFlags)0x00000800); _resetter.Set(); //var _stopwatch = Stopwatch.StartNew(); while (!CancelTokenSource.IsCancellationRequested) { if (!SoundService.Update()) { if (SoundService.IsCriticalError) { SoundService.Reset(); } } _queue.Work(); //_stopwatch.Restart(); } }
public void StartLoadAutoHandler(object sender, EventArgs e) { // Load Course from autosave if (System.IO.File.Exists(Properties.Resources.SAVE_FILE_PATH)) { ConcurrentWorkQueue.Enqueue(() => { try { Course c = new CourseXMLBackend(null).SetPath(Properties.Resources.SAVE_FILE_PATH).Load(); this.registerCourse(c); return; } catch (InvalidCourseXMLException) { MessageBox.Show("Unable to load course, the file might be corrupted.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }); } else { MessageBox.Show("No autosave file present.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public void TestInitialize() { ConcurrentWorkQueue.Initialize(); this.c = new Course(false); }
public virtual void TriggerCalculation() { ConcurrentWorkQueue.Enqueue(() => this.recalculateResult()); }
public void TestInitialize() { ConcurrentWorkQueue.Initialize(); this.y = new Year(5); }
public void TestInitialize() { ConcurrentWorkQueue.Initialize(); this.m = new Module("test", "test", 15, null); }
public void StartNewHandler(object sender, EventArgs e) { // Reset Course instance // (re) Initialize main form ConcurrentWorkQueue.Enqueue(() => this.registerCourse(new Course())); }