Esempio n. 1
0
        /// <summary>
        /// Handles the image job.
        /// </summary>
        /// <param name="currentJob">
        /// The current job.
        /// </param>
        private void HandleImageJob(ImageJob <T> currentJob)
        {
            // load data from stream
            sbyte[,] imageData = currentJob.Data;

            try
            {
                // generate image from data
                Bitmap image = this.GenerateImage(imageData);

                var path = Path.Combine(
                    this.imageSavePath,
                    string.Format("{0}.{1}", currentJob.Round, this.imageExtension));

                image.Save(path, imageFormat);

                currentJob.File       = path;
                currentJob.IsFinished = true;
                this.OnJobFinished(currentJob);
            }
            catch (Exception ex)
            {
                currentJob.IsFinished = false;
                Debug.WriteLine("Error - image Creation for Round {0} failed - {1}", currentJob.Round, ex.Message);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Called when a job is finished.
        /// </summary>
        /// <param name="e">
        /// The e.
        /// </param>
        protected virtual void OnJobFinished(ImageJob <T> e)
        {
            var handler = this.JobFinished;

            if (handler != null)
            {
                handler(this, e);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Runs the creator.
        /// </summary>
        private void RunCreator()
        {
            while (this.IsCreatorRunning)
            {
                try
                {
                    while (this.jobQueue.Count == 0)
                    {
                        Thread.Sleep(100);
                    }

                    ImageJob <T> currentJob = null;
                    this.jobQueue.TryDequeue(out currentJob);

                    this.HandleImageJob(currentJob);
                }
                catch (ThreadAbortException ex)
                {
                    this.IsCreatorRunning = false;
                }
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Adds the job.
 /// </summary>
 /// <param name="job">
 /// The job.
 /// </param>
 public void AddJob(ImageJob <T> job)
 {
     this.jobQueue.Enqueue(job);
 }