private void ProcessJobsQueue() { for (int jobIndex = 0; jobIndex < this.activeJobsQueue.Count; jobIndex++) { Job job = this.activeJobsQueue[jobIndex]; if (job.CanStart()) { job.Start(); } if (job.IsRunning) { job.UpdateState(); } if (job.IsFinished) { // Terminate any job actions, which still run on the background job.Cancel(); // Move the current job to the "completed jobs" list this.activeJobsQueue.RemoveAt(jobIndex); this.completedJobs.Add(job); // Continue correctly to the next job (after the current job, which is deleted) jobIndex--; } this.RefreshActiveJobsUI(); } }
public LoadingMenu(string title, Job job, GameState gameState) : base(gameState) { _job = job; PauseGame = true; _progressLabel = new WidgetLabel { Anchor = Anchor.Center, Font = Resources.FontRomulus, Origine = Anchor.Center, Text = "", UnitOffset = new Point(0, -16) }; _progressBar = new WidgetProgress { Anchor = Anchor.Center, Origine = Anchor.Center, UnitBound = new Rectangle(0, 0, 320 + 64, 8), UnitOffset = new Point(0, 16) }; Content = new LayoutDock { Children = { new WidgetLabel { Text = title, Anchor = Anchor.Center, Origine = Anchor.Center, UnitOffset = new Point(0), Font = Resources.FontAlagard, TextSize = 1f, }, new WidgetFancyPanel { Anchor = Anchor.Bottom, Origine = Anchor.Bottom, Content = new LayoutDock{ Children ={ _progressBar, _progressLabel } }, Dock = Rise.Platform.Family == Framework.Platform.PlatformFamily.Mobile ? Dock.Fill : Dock.None, UnitBound = new Rectangle(0, 0, 512, 96), UnitOffset = new Point(0, -32) } } }; _job.Start(true); _job.Finish += (sender, e) => { if (!_job.Canceled) { gameState.CurrentMenu = new MenuInGame(gameState); } }; }
public void TestContext() { Job<string, int> job = new Job<string, int>(); job .Start(new DummyComponent1()) .End(new DummyComponent2()); Assert.AreEqual(0, job.Process(string.Empty)); job .Start(new DummyComponent1(5)) .End(new DummyComponent2()); Assert.AreEqual(5, job.Process(string.Empty)); }
// WCF method public void StartNewJob() { Job myJob = new Job(); // Initialise myJob... myJob.Start(); }
//DAQRI.BodySpace bodySpace = new DAQRI.BodySpace(); public void OnPointerClick(PointerEventData eventData) { Debug.Log("Clicked"); myJob = new Job(); myJob.GO = Content; myJob.Start(); }
public void Initialize() { renderer.Initialize(handle, width, height); context = new RenderContext(renderer.Device, scene, new SharpDX.RectangleF(0.0f, 0.0f, width, height)); job.Start(); }
public void TestContext() { Job <string, int> job = new Job <string, int>(); job .Start(new DummyComponent1()) .End(new DummyComponent2()); Assert.AreEqual(0, job.Process(string.Empty)); job .Start(new DummyComponent1(5)) .End(new DummyComponent2()); Assert.AreEqual(5, job.Process(string.Empty)); }
public UploadResultList UploadWithoutDialog(UploadRequestList objUploadRequests) { if (objUploadRequests == null) { throw new ArgumentNullException("objUploadRequests", "A valid non-null UploadRequestList is expected"); } _objJobResult = null; IEnumerable <ITask> objTasks = objUploadRequests.GetTasks(); Job objUploadJob = new Job(objTasks); objUploadJob.JobEnd += new Job.OnJobEndDelegate(objUploadJob_JobEnd); objUploadJob.Start(); objUploadJob.Wait(); UploadResultList objUploadResults = new UploadResultList(); if (_objJobResult != null) { foreach (ITaskResult objTaskResult in _objJobResult.TaskResults) { UploadResult objUploadResult = (UploadResult)objTaskResult; objUploadResults.Add(objUploadResult); } } return(objUploadResults); }
public void Start() { if (job != null) { job.Start(); } }
void StartJob() { try { while (loopContinuity == false) //Wait till the job is idle { job.Refresh(); if (job.CurrentRunStatus == JobExecutionStatus.Executing) //Check Job status and find if it’s running now { CurrentRunRetryAttempt++; //We are not ready to fire the job loopContinuity = false; } else { //We are ready to fire the job loopContinuity = true; //Set loop exit job.Start(); //Start the job } System.Threading.Thread.Sleep(1 * 1000); //Fail to start, wait 10 seconds and try again this.AppendResultDescription(1, "Job started. Current status={0}", job.CurrentRunStatus); } job.Refresh(); while (job.CurrentRunStatus != JobExecutionStatus.Idle) //Wait till the job is idle { System.Threading.Thread.Sleep(1 * 1000); job.Refresh(); } } catch { throw; } }
public IEnumerator StartDownload() { while (jobs.Count > 0) { //Debug.Log("任务还剩 " +jobs.Count); current = jobs[0]; if (workNum < coreNum) { jobs.RemoveAt(0); workNum++; StartCoroutine(current.Start(() => { workNum--; currentDownload++; //Debug.LogWarning("任务已经完成 " + currentDownload); })); } else { //Debug.Log("下载线程已满 " + Time.time); yield return(null); } } yield return(null); }
public override void Load() { _progressLabel = new Label { Text = "Generating world...", Anchor = Anchor.Center, Origine = Anchor.Center, Font = Ressources.FontRomulus, UnitOffset = new Point(0, -24) }; _progressBar = new ProgressBar { UnitBound = new Rectangle(0, 0, 320, 8), Anchor = Anchor.Center, Origine = Anchor.Center, UnitOffset = new Point(0, 24) }; var _cancelButton = new SpriteButton() { Sprite = new Sprite(Ressources.TileGui, new Point(7, 7)), UnitBound = new Rectangle(0, 0, 48, 48), Anchor = Anchor.TopRight, Origine = Anchor.Center }.RegisterMouseClickEvent((sender) => { _job.Cancel(); Game.GoToMainMenu(); }); Container = new Container { Padding = new Margins(16), Childrens = { new WidgetFancyPanel { UnitBound = new Rectangle(0, 0, 840, 256), Anchor = Anchor.Center, Origine = Anchor.Center, Dock = Rise.Platform.Family == Framework.Platform.PlatformFamily.Mobile ? Dock.Fill : Dock.None, Content = new Container { Childrens = { _progressBar, _progressLabel, _cancelButton } } } } }; _job.Start(true); }
public async Task TestInputFileLineTestOpenFileETL(string filename, InputFileMode mode) { var inputFileService = ctx.GetService <TInputFile>(); Assert.IsNotNull(inputFileService); inputFileService.RegisterComponentForEvents(scheduler); inputFileService.Filename = filename; inputFileService.Mode = mode; inputFileService.AddToJob(job); int caller = 0; if (mode == InputFileMode.LineByLine) { inputFileService.OnOutput.Subscribe(s => { ++caller; //Debug.WriteLine($"{++caller}-{s.Content.ToString()}"); }, () => { Assert.AreEqual(caller, 349); }); var logRow = ctx.GetService <TLogRow <ContentSchema <string> > >(); Assert.IsNotNull(logRow); logRow.ShowHeader = true; logRow.ShowItemNumber = true; logRow.Mode = TLogRowMode.Table; logRow.RegisterComponentForEvents(scheduler); logRow.AddInput(job, inputFileService.OnOutput); } if (mode == InputFileMode.Full) { inputFileService.OnOutput.Subscribe(s => { Debug.WriteLine($"{++caller}-{s.Content.ToString()}"); }, () => { Assert.AreEqual(caller, 1); }); } //scheduler.Start(); await job.Start(); }
public void StartJob(Job job) { currentJob = job; currentJob.Argument.InitWorker(worker); currentJob.Start(); worker.WorkerReportsProgress = true; worker.WorkerSupportsCancellation = true; time.Start(); worker.RunWorkerAsync(); }
public void TestChaining() { Job <string, string> job = new Job <string, string>(); job .Start(new DummyComponent1(1337)) .Then(new DummyComponent2()) .End(new DummyComponent3()); Assert.AreEqual("1337", job.Process(string.Empty)); }
public void TestChaining() { Job<string, string> job = new Job<string, string>(); job .Start(new DummyComponent1(1337)) .Then(new DummyComponent2()) .End(new DummyComponent3()); Assert.AreEqual("1337", job.Process(string.Empty)); }
void Application_Start(object sender, EventArgs e) { RouteTable.Routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); RegistAtStart.Regist(); Job.Start(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); GlobalConfiguration.Configure(new Action <HttpConfiguration>(WebApiConfig.Register)); RouteConfig.RegisterRoutes(RouteTable.Routes); AreaRegistrationOrder.RegisterAllAreasOrder(); BundleConfig.RegisterBundles(BundleTable.Bundles); }
internal void Run() { if (_job.CurrentRunStatus == JobExecutionStatus.Executing) { _job.Stop(); } else { _job.Start(); } _job.Refresh(); }
static void Run(int databaseOption) { Console.WriteLine("Running Overnight Job on Demand"); Server server = new Server(@"SERVERNAME"); try { var database = ""; switch (databaseOption) { case 1: database = "SETUP"; break; case 2: database = "QA"; break; case 3: database = "TRAIN"; break; case 4: database = "TEST"; break; default: database = "SETUP"; break; } server.ConnectionContext.LoginSecure = false; server.ConnectionContext.Login = "******"; server.ConnectionContext.Password = "******"; server.ConnectionContext.Connect(); Job job = server.JobServer.Jobs["BMSSmartcare" + database + " - Nightly Billing Processes"]; job.Start(); } catch (Exception e) { Console.WriteLine(e); Console.ReadKey(); } finally { if (server.ConnectionContext.IsOpen) { server.ConnectionContext.Disconnect(); } } }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RouteConfig.RegisterRoutes(RouteTable.Routes); int StartHour = Convert.ToInt32(ConfigurationManager.AppSettings["SendEmailHour"].ToString()), Startmin = Convert.ToInt32(ConfigurationManager.AppSettings["SendEmailmin"].ToString()); JobScheduler.StartM(StartHour, Startmin); int StartActiveDirectoryHour = Convert.ToInt32(ConfigurationManager.AppSettings["StartActiveDirectoryHour"].ToString()), StartActiveDirectorymin = Convert.ToInt32(ConfigurationManager.AppSettings["StartActiveDirectorymin"].ToString()); Job.Start(StartActiveDirectoryHour, StartActiveDirectorymin); // Dependency.Register(); }
public void AddJob(Job job) { lock (this) { this._jobs.Add(job); job.SetJobManager(this); this.RaiseOnJobAdd(job); job.Start(); job.OnFoundNonce += (s, e) => { this.RaiseOnJobSuccess(e.Job); }; } }
private async Task Start() { try { Logger.LogInfo(Job.Id, Loc["StartedWaiting"]); await Job.Start(); Logger.LogInfo(Job.Id, Loc["StartedChecking"]); } catch (Exception ex) { await js.AlertException(ex); } }
/// <summary> /// Creates and starts a job using supplied parameters. /// </summary> /// <param name="parameters"></param> /// <returns></returns> public Job <SomeResult, SomeProgress> DoJobAsync(SomeParameters parameters) { // Set up each job to invoke the library method var job = new Job <SomeResult, SomeProgress>(Guid.NewGuid().ToString(), progressListener => { return(Library.DoLongRunningThingAsync(parameters, progressListener)); }); // Add it to repository so we can get it later this.repository.Add(job); // Start job now, but don't wait for it to finish job.Start(); return(job); }
private void DownloadThread() { Thread.Sleep(10); this.ThreadSafe(new MethodInvoker(delegate() { listViewStatus.Items.Clear(); foreach (DownloadRequest objDownloadRequest in _objDownloadRequests) { string strFileName = Path.GetFileName(objDownloadRequest.Source); ListViewItem objListViewItem = new ListViewItem(objDownloadRequest.Destination); objListViewItem.SubItems.Add("Queued"); listViewStatus.Items.Add(objListViewItem); } buttonCancel.Enabled = _objDownloadDialogSettings.AllowCancel; buttonPauseContinue.Enabled = _objDownloadDialogSettings.AllowPause; this.Refresh(); })); _intTaskIndex = 0; _intTaskCount = _objDownloadRequests.Count; _objJobResult = null; IEnumerable <ITask> objTasks = _objDownloadRequests.GetTasks(); _objJob = new Job(objTasks); _objJob.TaskBegin += new Job.OnTaskBeginDelegate(objDownloadJob_TaskBegin); _objJob.TaskEnd += new Job.OnTaskEndDelegate(objDownloadJob_TaskEnd); _objJob.JobEnd += new Job.OnJobEndDelegate(objDownloadJob_JobEnd); _objJob.TaskProgressChanged += new Job.TaskProgressChangedDelegate(objDownloadJob_TaskProgressChanged); _objJob.Start(); _objJob.Wait(); _objDownloadResults = new DownloadResultList(); if (_objJobResult != null) { _objDownloadResults = new DownloadResultList(_objJobResult.TaskResults); } Thread.Sleep(10); this.ThreadSafe(new MethodInvoker(delegate() { this.Close(); })); }
private void removeJobAndStartNextJobInQueue() { if (this.processingJob == null) { try { Job j = this.jobQueue.Dequeue(); this.processingJob = j; logger.Info("start job {0} is first in queue and none is processing", j); j.Start(); } catch (Exception) { logger.Info("no next job to start"); } } else { logger.Info("job enqueued. there is still an active Job"); } }
void Start() { gameOver = false; // Define and start second thread containing the IRC bot. myJob = new Job(); myJob.Start(); // Set Democracy duration democracyDuration = 10.0f; // Start execution routine StartCoroutine("Execute"); // Set turn count to 0 currentTurn = 0; }
internal static bool AddJob(AT.Task task) { bool bRet = true; Job j = new Job(task); Thread jobThread = new Thread(() => DispatchJob(j)); j._JobThread = jobThread; jobThread.SetApartmentState(ApartmentState.STA); lock (executingJobs) { try { executingJobs.Add(j); j.Start(); } catch { bRet = false; } } return(bRet); }
private void ReqCanReadResponse(CanReadEventArgs e) { object[] P = (object[])e.State; int seqnr = (int)P [0]; DateTime When = (DateTime)P [1]; string LanguageCode = (string)P [2]; string From = (string)P [3]; string Id = (string)P [4]; if (e.Result) { this.Accepted(seqnr, From, Id); DateTime Now = DateTime.Now; Job Job = new Job(e.Request, seqnr, When, From, this); this.Register(From, seqnr, Job); if (When > Now) { lock (this.queue) { while (this.queue.ContainsKey(When)) { When = When.AddTicks(gen.Next(1, 10)); } Job.When = When; this.queue [When] = Job; this.SetTimer(); } } else { Job.Start(); } } else { this.RequestRejected(seqnr, From, Id, "Readout rejected by provisioning server.", "cancel", "forbidden", "urn:ietf:params:xml:ns:xmpp-stanzas"); } }
private void CheckQueue(object State) { try { LinkedList <Job> ToExecute = null; DateTime Now = DateTime.Now; lock (this.queue) { foreach (KeyValuePair <DateTime, Job> Pair in this.queue) { if (Pair.Key <= Now) { if (ToExecute == null) { ToExecute = new LinkedList <Job> (); } ToExecute.AddLast(Pair.Value); } else { break; } } if (ToExecute != null) { foreach (Job Job in ToExecute) { this.queue.Remove(Job.When); Job.Start(); } } } } catch (Exception ex) { Log.Exception(ex); } finally { this.SetTimer(); } }
public void Process(object sender, EventArgs args) { Assert.ArgumentNotNull(sender, "sender"); Assert.ArgumentNotNull(args, "args"); Log.Info("Historian.Handler. Starting processing for databases ({0}).".FormatWith(_databases.Count), this); foreach (string dbName in _databases) { if (dbName.IsNullOrEmpty()) { Log.Error("Historian.Handler. Database parameter was invalid. Processing skipped", this); continue; } if (!StringUtil.Join(Factory.GetDatabaseNames(), ",").Contains(dbName)) { Log.Error("Historian.Handler. Database '{0} does not exist. Processing skipped".FormatWith(dbName), this); continue; } var database = Factory.GetDatabase(dbName); if (database == null) { Log.Error("Historian.Handler. Database '{0} does not exist. Processing skipped".FormatWith(dbName), this); continue; } Log.Info("Historian.Handler. Starting processing for database '{0}'...".FormatWith(dbName), this); try { var jobOptions = new JobOptions("Historian.Handler.ProcessDatabase", "", Context.Site.Name, this, "ProcessDatabase", new object[] { database }); var job = new Job(jobOptions); job.Start(); } catch (Exception exception) { Log.Error("Historian.Handler. Background job ProcessDatabase failed. ", exception); } } }
public static void Demo1() { try { ISchedule _schedule1 = new ScheduleExecutionOnce(DateTime.Now.AddSeconds(10)); Console.WriteLine("最初计划执行时间:" + _schedule1.ExecutionTime); Console.WriteLine("初始化执行时间于现在时间的时间刻度差 :" + _schedule1.DueTime); Console.WriteLine("循环的周期 :" + _schedule1.Period); ISchedule _schedule2 = new CycExecution(new TimeSpan(0, 0, 20)); Console.WriteLine("最初计划执行时间:" + _schedule2.ExecutionTime); Console.WriteLine("初始化执行时间于现在时间的时间刻度差 :" + _schedule2.DueTime); Console.WriteLine("循环的周期 :" + _schedule2.Period); ISchedule _schedule3 = new ImmediateExecution(); Console.WriteLine("最初计划执行时间:" + _schedule2.ExecutionTime); Console.WriteLine("初始化执行时间于现在时间的时间刻度差 :" + _schedule2.DueTime); Console.WriteLine("循环的周期 :" + _schedule2.Period); Job _task1 = new Job((obj) => { Console.WriteLine("任务完成:" + DateTime.Now.FormatDate(1)); Console.WriteLine("---------------------------------------"); }, _schedule3, "YanZhiwei"); _task1.Start(DateTime.Now.FormatDate(1)); while (JobScheduler.Count > 0) { Thread.Sleep(1000); Job cc = JobScheduler.Find("YanZhiwei"); if (cc != null) { Console.WriteLine("NextExecuteTime:" + cc.NextExecuteTime); } } } finally { // Console.WriteLine("当前任务数量:" + TaskScheduler.Count); } }
public int StartJob(string JobName) { int ret = 0; try { Job oJob = GetJob(JobName, out ret); ret++; if (oJob.IsEnabled && oJob.CurrentRunStatus == JobExecutionStatus.Idle) { ret++; oJob.Start(); ret++; } } catch { ret--; } return(ret); }
public void CalculatePairVsPair() { Pocket[] pockets = new Pocket[_scOriginals.Length]; for (int i = 0; i < pockets.Length; ++i) { pockets[i] = new Pocket(_scOriginals[i]._pocket); } DateTime startTime = DateTime.Now; int jobsCount = Environment.ProcessorCount; Job[] jobs = new Job[jobsCount]; int tasksCount = pockets.Length; int sliceSize = (tasksCount + jobsCount - 1) / jobsCount; for (int j = 0; j < jobsCount; j++) { int s = sliceSize * j; int l = Math.Min(sliceSize, tasksCount - s); Job job = new Job(pockets.Slice(s, l)); job.Start(); jobs[j] = job; } for (int j = 0; j < jobsCount; j++) { jobs[j].Wait(); } TimeSpan time = DateTime.Now - startTime; Console.WriteLine("Calculated in {0} seconds", time.TotalSeconds); using (Stream file = File.Open("PocketResult.bin", FileMode.Create)) { BinaryFormatter binFormatter = new BinaryFormatter(); binFormatter.Serialize(file, pockets); file.Close(); } }
/// <summary> /// /// </summary> /// <param name="id"></param> /// <param name="size"></param> /// <param name="onComplete"></param> /// <returns></returns> public static Coroutine LoadProfilePic(string id, int size, Action<Texture2D> onComplete) { var job = new Job(LoadingProfilePic(id, size, onComplete), false); return job.Start(); }
private void JumpingEnter(Dictionary<string, object> info) { // attackAnimation PlayAnimation(JumpingState); currentStateJob = new Job(JumpingUpdate(), false); currentStateJob.CreateChildJob(Climb(), climbTime); currentStateJob.CreateChildJob(Float()); // currentStateJob.JobCompleteEvent += (killed) => { if (killed) return; info = new Dictionary<string, object> {{"fromJump", true}}; SetState(FallingState, info); }; currentStateJob.Start(); }