//		internal bool _cancelled;

		/// <summary>
		/// Initializes a new instance of the BackgroundThreadPoolJob class
		/// </summary>
		/// <param name="startInfo">The start information regarding thread arguments and a callback method</param>
		public BackgroundThreadPoolJob(string name, BackgroundThreadStartInfo startInfo)
		{			
			_id = Guid.NewGuid();
			_name = name;
			_startInfo = startInfo;
			_state = BackgroundThreadPoolJobStates.Waiting;
		}
Esempio n. 2
0
//		internal bool _cancelled;

        /// <summary>
        /// Initializes a new instance of the BackgroundThreadPoolJob class
        /// </summary>
        /// <param name="startInfo">The start information regarding thread arguments and a callback method</param>
        public BackgroundThreadPoolJob(string name, BackgroundThreadStartInfo startInfo)
        {
            _id        = Guid.NewGuid();
            _name      = name;
            _startInfo = startInfo;
            _state     = BackgroundThreadPoolJobStates.Waiting;
        }
        /// <summary>
        /// Creates a thread pool job and enqueues it for the thread pool to execute
        /// </summary>
        /// <param name="startInfo">The background thread start info that will be executed as a thread pool job</param>
        /// <returns></returns>
        public BackgroundThreadPoolJob QueueJob(string name, BackgroundThreadStartInfo startInfo)
        {
            // lock the queue
            lock (this.JobQueue.SyncRoot)
            {
                // create a new job
                BackgroundThreadPoolJob job = new BackgroundThreadPoolJob(name, startInfo);

                // and enqueue the job to be processed
                this.JobQueue.Enqueue(job);

                // return the job that was created and enqueued
                return(job);
            }
        }
		/// <summary>
		/// Creates a thread pool job and enqueues it for the thread pool to execute
		/// </summary>
		/// <param name="startInfo">The background thread start info that will be executed as a thread pool job</param>
		/// <returns></returns>
		public BackgroundThreadPoolJob QueueJob(string name, BackgroundThreadStartInfo startInfo)
		{
			// lock the queue
			lock (this.JobQueue.SyncRoot)
			{
				// create a new job
				BackgroundThreadPoolJob job = new BackgroundThreadPoolJob(name, startInfo);
				
				// and enqueue the job to be processed
				this.JobQueue.Enqueue(job);

				// return the job that was created and enqueued
				return job;
			}
		}