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();
 }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }
Пример #4
0
    // <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>();
    }
Пример #5
0
        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);
        }