public static void Main(string[] args) { var calculationService = new CalculationJob(); Console.WriteLine("Calculation Job initialized."); calculationService.Execute(Console.WriteLine); Console.WriteLine("Executing finished."); Console.ReadKey(); }
private void NotifyFinished(CalculationJob job, JobStatus status, DateTime started) { var stopped = DateTime.Now; job.JobResult = string.Format("Started at {0}, counted {1}, completed at {2}", started, job.JobParameter, stopped); _calculationJobRepo.SaveChanges(); EventAggregator.OnJobCompleted(this, status); }
private JobStatus NotifyStarted(CalculationJob job) { var jobStat = new JobStatus { Id = job.Id.ToString(), JobType = job.JobType, Name = string.Format("Job {0} counting to {1}", job.Id, job.JobParameter), Progress = 0 }; EventAggregator.OnJobStatusChanged(this, jobStat); return(jobStat); }
// <summary> /// Set instance for settings object and initialize callbacks of UI /// </summary> private void Awake() { // Check singleton, each time the menu scene is loaded, the instance is replaced with the newest script if (instance == null) { instance = this; } else { // Update Singleton when loading a new scene Destroy(instance.gameObject); instance = this; } // Add processing jobs coroutine in runtime to the same object calculationJobs = gameObject.AddComponent <CalculationJob>(); // Start entities udpListener = new UDPReceiver2(); bfVariables = new List <BiofeedbackVariable>(); }
public CalculationJob CreateJob(JobType type) { var jobParam = 10; if (type == JobType.CountTo20) { jobParam = 20; } else if (type == JobType.CountToRandom) { Random r = new Random(); jobParam = r.Next(1, 50); } var newJob = new CalculationJob { JobType = type.ToString(), JobParameter = jobParam }; _db.Jobs.Add(newJob); _db.SaveChanges(); return(newJob); }