private IEnumerator GetMove(MoveJob moveJob, JobMonitor jobMonitor, OnMoveJobComplete onMoveJobComplete = null) { Thread thread; thread = GetMoveAsync(moveJob); threads.Add(thread); thread.Start(); //ensure that the thread has started yield return(new WaitUntil(() => thread.IsAlive)); jobMonitor.started = true; //wait for the thread to finish yield return(new WaitWhile(() => thread.IsAlive)); //mark the job as complete if (onMoveJobComplete != null) { onMoveJobComplete.Invoke(moveJob); } jobMonitor.complete = true; //remove the thread from the list of threads threads.Remove(thread); }
[Fact] //End to End public void TestJobMonitorConstructor() { JobMonitor mon = new JobMonitor(); string resultado = mon.ExecJobsMonitor(); Assert.Contains("OK", resultado); }
private void StartMonitoring() { if (IsWatcherRunning) { // Already running. return; } if (!IsPrintToDriveInstalled) { // Printer not installed. return; } if (!userSession.Settings.PrintToDrivePrompt && !IsUploadPathSet) { // Configured to upload to a default Drive path but it is not set. return; } // Create the folder watcher. printJobMonitor = new PrintToDriveMonitor(); #pragma warning disable 4014 printJobMonitor.Start(p => ProcessNewPrintJob(p), SynchronizationContext.Current); #pragma warning restore 4014 pictureStartedStopped.Image = Resources.started; labelMonitorStatus.Text = "Print to Drive monitor is running."; }
static void Main(string[] args) { JobMonitor monitor = new JobMonitor(); string resultado = monitor.ExecJobsMonitor(); Console.WriteLine("Resultado de Monitoreo de Jobs: " + resultado); Console.ReadLine(); }
private IEnumerator PredictMovesCoroutine() { BoardData board; int coreCount, childIndex; List <MoveJob> moveJobs; JobMonitor jobMonitor; MoveData[] children; predictedMoves.Clear(); board = new BoardData(gameController.Board); coreCount = Mathf.Max(System.Environment.ProcessorCount - 1, 1); //get all possible moves that the other player could make children = GetAllChildrenOf(board, GameStatus.GetOppositePlayerOf(myToken), ref MoveJob.abortAll); //run MoveJobs for all possible moves asynchronously childIndex = 0; moveJobs = new List <MoveJob>(); while (childIndex < children.Length) { yield return(new WaitUntil(() => (MoveJob.abortAll || threads.Count < coreCount))); if (MoveJob.abortAll) { //terminate this operation if all jobs are being aborted break; } jobMonitor = new JobMonitor(); //create the job moveJobs.Add(new MoveJob() { move = Vector3Int.zero, board = children[childIndex].board, myToken = myToken, depth = depth, jobID = childIndex }); //run the job StartCoroutine(GetMove(moveJobs[moveJobs.Count - 1], jobMonitor, AddJobToPredictions)); //wait for the job to start yield return(new WaitUntil(() => jobMonitor.started)); //move to the next child childIndex++; } //wait for all jobs to finish yield return(new WaitUntil(() => MoveJob.abortAll || threads.Count == 0)); }
public async Task <int> RunTwinJobAsync() { var jobId = StartTwinUpdateJob(_opts); // TODO: await JobMonitor.MonitorAsync(_appsettings, jobId); return(0); }
public async Task <int> RunDirectMethodAsync() { var jobId = Guid.NewGuid().ToString(); Task jobTask = Task.Run(() => StartMethodJob(jobId)); Task monitorTask = Task.Run(() => JobMonitor.MonitorAsync(_appsettings, jobId)); Task.WaitAll(jobTask, monitorTask); return(0); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (!Context.ClientPage.IsEvent) { if (Monitor == null) { Monitor = new JobMonitor(); Monitor.ID = "Monitor"; Context.ClientPage.Controls.Add(Monitor); } } else if (Monitor == null) { Monitor = (JobMonitor)Context.ClientPage.FindControl("Monitor"); } }
private IEnumerator PlayTurnCoroutine(BoardData board) { #if UNITY_EDITOR float time = Time.timeSinceLevelLoad; #endif MoveJob moveJob = new MoveJob() { move = Vector3Int.zero, board = board, myToken = myToken, depth = depth, jobID = 10101 }; JobMonitor jobMonitor = new JobMonitor(); if (onStartPlanning != null) { onStartPlanning.Invoke(); } //start the job StartCoroutine(GetMove(moveJob, jobMonitor)); #if UNITY_EDITOR Debug.Log("Working"); #endif //wait for it to complete yield return(new WaitUntil(() => jobMonitor.complete)); if (onStopPlanning != null) { onStopPlanning.Invoke(); } //place the token based on selected move PlaceToken(moveJob.move); #if UNITY_EDITOR Debug.Log("Completed in " + (Time.timeSinceLevelLoad - time) + " seconds."); Debug.Log("Placed token at " + moveJob.move + "."); #endif }
private void StopMonitoring() { if (!IsWatcherRunning) { return; } try { printJobMonitor.Stop(); printJobMonitor = null; } catch (ArgumentException ex) { NotificationService.ShowBalloonError("Stop Print to Fax monitor error: {0}", ex.Message); } pictureStartedStopped.Image = Resources.stopped; }
private void StartMonitoring() { if (IsWatcherRunning) { // Already running. return; } if (!IsPrinterInstalled || !IsMhwFaxInstalled) { // Printer or app not installed. return; } // Create the folder watcher. printJobMonitor = new PrintToFaxMonitor(); #pragma warning disable 4014 printJobMonitor.Start(p => ProcessNewPrintJob(p), SynchronizationContext.Current); #pragma warning restore 4014 pictureStartedStopped.Image = Resources.started; }
/// <summary> /// Raises the load event. /// </summary> /// <param name="e">The <see cref="T:System.EventArgs" /> instance containing the event data.</param> /// <remarks> /// This method notifies the server control that it should perform actions common to each HTTP /// request for the page it is associated with, such as setting up a database query. At this /// stage in the page lifecycle, server controls in the hierarchy are created and initialized, /// view state is restored, and form controls reflect client-side data. Use the IsPostBack /// property to determine whether the page is being loaded in response to a client postback, /// or if it is being loaded and accessed for the first time. /// </remarks> protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (!Context.ClientPage.IsEvent) { this.DataContext.GetFromQueryString(); Item folder = this.DataContext.GetFolder(); this.BuildProjectList(); if (this.Monitor == null) { this.Monitor = new JobMonitor(); this.Monitor.ID = "Monitor"; Context.ClientPage.Controls.Add((System.Web.UI.Control)this.Monitor); } } else if (this.Monitor == null) { this.Monitor = Context.ClientPage.FindControl("Monitor") as JobMonitor; } this.Monitor.JobFinished += new EventHandler(this.Monitor_Finished); this.Monitor.JobDisappeared += new EventHandler(this.Monitor_Finished); }
static void Main(string[] args) { JPPFClient client = null; TopologyManager manager = null; JobMonitor jobMonitor = null; try { // initialize the .Net bridge with verbose/quiet mode JPPFDotnet.Init(false); // initialize a topology manager and register a listener for topology events manager = new DotnetTopologyManager(new MyTopologyListener()); // initialize a topology manager and register a listener for topology events jobMonitor = new DotnetJobMonitor(manager, new MyJobMonitoringListener()); // wait until the topology manager and job monitor are fully initialized while (jobMonitor.getJobDrivers().size() <= 0) { Thread.Sleep(10); } JobDriver jobDriver = jobMonitor.getJobDrivers().get(0) as JobDriver; while (jobDriver.getTopologyDriver().getChildCount() <= 0) { Thread.Sleep(10); } // initialize the JPPF client client = manager.getJPPFClient(); // print the number of nodes connected to the server PrintNbNodes(client); // provision a slave node for each .Net-capable master node //ProvisionNodes(client, 1); // subscribe to job notifications emitted by the JPPF server //RegisterJobNotificationListener(client); // subscribe to task completion notifications emitted by the JPPF nodes RegisterTaskNotificationListener(client); // uncomment to test an executor service //SubmitWithExecutor(client); // uncomment to test a completion service //SubmitWithCompletionService(client); JPPFJob job = new JPPFJob(); job.setName(".NET job"); // execute the job only on nodes which successfully initialized the .Net bridge job.getSLA().setExecutionPolicy(new Equal("jppf.dotnet.bridge.initialized", true)); int n = 5; for (int i = 0; i < n; i++) { job.add(new MyDotnetTask(1000)).setId("task " + (i + 1)); } MyDotnetTask myTask = new MyDotnetTask(3000); // this .Net task will time out after 1.5 second myTask.TimeoutSchedule = new JPPFSchedule(1500); job.add(myTask).setId("task " + (n + 1)); // alternatively: job.add(new MyDotnetTask(3000)).setTimeoutSchedule(new JPPFSchedule(1500)); // add a job listner that prints job events to the console job.addJobListener(new MyJobListener()); Console.WriteLine("created job"); // submit the job to the grid and get the execution results java.util.List results = client.submitJob(job); Console.WriteLine("got job results"); for (int i = 0; i < results.size(); i++) { Task task = (Task)results.get(i); //BaseDotnetTask dotnetTask = job.asBaseDotnetTask(task); BaseDotnetTask dotnetTask = task.AsBaseDotnetTask(); if (dotnetTask != null) // if .Net task { if (dotnetTask.Exception != null) { Console.WriteLine("got exception for task " + dotnetTask + " : " + dotnetTask.Exception); Console.WriteLine(dotnetTask.Exception.StackTrace); } else if (dotnetTask.Result != null) { Console.WriteLine("got result for task " + dotnetTask + " : " + dotnetTask.Result); } else { Console.WriteLine("no result or exception for task " + dotnetTask); } } } } catch (Exception e) { Console.WriteLine(e.ToString()); } if (!Console.IsInputRedirected && !Console.IsOutputRedirected) { Console.WriteLine("Please press ESC to terminate"); do { while (!Console.KeyAvailable) { } } while (Console.ReadKey(true).Key != ConsoleKey.Escape); } else { Console.WriteLine("Waiting 5 seconds ..."); Thread.Sleep(5000); } if (client != null) { client.close(); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); string itemId = WebUtil.GetQueryString("id"); string itemDb = WebUtil.GetQueryString("db"); string scriptId = WebUtil.GetQueryString("scriptId"); string scriptDb = WebUtil.GetQueryString("scriptDb"); ScriptItem = Factory.GetDatabase(scriptDb).GetItem(new ID(scriptId)); ScriptItem.Fields.ReadAll(); if (!string.IsNullOrEmpty(itemId) && !string.IsNullOrEmpty(itemDb)) { CurrentItem = Factory.GetDatabase(itemDb).GetItem(new ID(itemId)); } Settings = ApplicationSettings.GetInstance(ApplicationNames.Context,false); PersistentId = ScriptItem[ScriptItemFieldNames.PersistentSessionId]; HeaderText.Text = ScriptItem.DisplayName; if (Monitor == null) { if (!Context.ClientPage.IsEvent) { Monitor = new JobMonitor {ID = "Monitor"}; Context.ClientPage.Controls.Add(Monitor); } else { Monitor = Context.ClientPage.FindControl("Monitor") as JobMonitor; } } if (Context.ClientPage.IsEvent && Context.ClientPage.ClientRequest.Parameters == "taskmonitor:check" && PreviousProgressValue.Text != CurrentProgressValue.Text) { int percentComplete = Int32.Parse(CurrentProgressValue.Text); SheerResponse.Eval( string.Format(@"updateProgress('#progressbar',{0});", percentComplete)); PreviousProgressValue.Text = CurrentProgressValue.Text; } }
/// <summary> /// 不要把 JobMonitor 放進來!!! 請用 event handler /// </summary> /// <param name="jobMonitor"></param> public NotifyJobStatusUpdatedEventHandler(JobMonitor jobMonitor) { this.JobMonitor = jobMonitor; }
/// <summary> /// Raises the load event. /// </summary> /// <param name="e"> /// The <see cref="T:System.EventArgs" /> instance containing the event data. /// </param> protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (Monitor == null) { if (!Context.ClientPage.IsEvent) { Monitor = new JobMonitor { ID = "Monitor" }; Context.ClientPage.Controls.Add(Monitor); } else { Monitor = (JobMonitor)Context.ClientPage.FindControl("Monitor"); } } if (Context.ClientPage.IsEvent) return; Settings = ApplicationSettings.GetInstance(ApplicationNames.IseConsole); if (Settings.SaveLastScript) { Editor.Value = Settings.LastScript; } string itemId = WebUtil.GetQueryString("id"); if (itemId.Length > 0) { ScriptItemId = itemId; LoadItem(WebUtil.GetQueryString("db"),itemId); } Monitor.JobFinished += MonitorJobFinished; Monitor.JobDisappeared += MonitorJobFinished; BuildDatabases(Client.ContentDatabase.Name); ParentFrameName = WebUtil.GetQueryString("pfn"); UpdateRibbon(); }
private static void Main() { Task.Run(() => JobMonitor.Start()); MainAsync().Wait(); }
internal void Submit() { JobMonitor.SubmitJob(this); }
/// <summary> /// Raises the load event. /// </summary> /// <param name="e"> /// The <see cref="T:System.EventArgs" /> instance containing the event data. /// </param> protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (Monitor == null) { if (!Context.ClientPage.IsEvent) { Monitor = new JobMonitor { ID = "Monitor" }; Context.ClientPage.Controls.Add(Monitor); } else { Monitor = (JobMonitor)Context.ClientPage.FindControl("Monitor"); } } if (Context.ClientPage.IsEvent) return; string sid = WebUtil.GetQueryString("sid"); ListViewer.ContextId = sid; ListViewer.Refresh(); ChangePage(ListViewer.CurrentPage); Monitor.JobFinished += MonitorJobFinished; Monitor.JobDisappeared += MonitorJobFinished; ListViewer.View = "Details"; ListViewer.DblClick = "OnDoubleClick"; string infoTitle = ListViewer.Data.InfoTitle; string infoDescription = ListViewer.Data.InfoDescription; if (string.IsNullOrEmpty(infoTitle) && string.IsNullOrEmpty(infoDescription)) { InfoPanel.Visible = false; } else { InfoTitle.Text = infoTitle ?? string.Empty; Description.Text = infoDescription ?? string.Empty; if (!string.IsNullOrEmpty(ListViewer.Data.Icon)) { InfoIcon.Src = ListViewer.Data.Icon; } } ParentFrameName = WebUtil.GetQueryString("pfn"); UpdateRibbon(); }
public QueueManager(JobMonitor jobMonitor, NodeManager nodeManager, SocketListener <DataHolder> socketListener) { this.SocketListener = socketListener; this.JobMonitor = jobMonitor; this.NodeManager = nodeManager; }