예제 #1
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <remarks>
 /// The default number of threads in the thread pool is 1.
 /// </remarks>
 protected ThreadPoolBase()
 {
     _state = StartStopState.Stopped;
     _completeBeforeStop = false;
     _threads            = new List <Thread>();
     _threadPriority     = ThreadPriority.Normal;
 }
예제 #2
0
 /// <summary>
 /// Called when the thread pool has stopped.
 /// </summary>
 /// <remarks>
 /// Inheritors that override this method must ensure that the base method gets called
 /// in order for the thread pool to function correctly.
 /// </remarks>
 protected virtual void OnStopped()
 {
     lock (_startStopSyncLock)
     {
         _state = StartStopState.Stopped;
         EventsHelper.Fire(_startStopEvent, this, new ItemEventArgs <StartStopState>(_state));
     }
 }
예제 #3
0
        /// <summary>
        /// Called before the thread pool is started.
        /// </summary>
        /// <remarks>
        /// Inheritors that override this method must first call the base method and
        /// cannot return true if the base method returns false.
        /// </remarks>
        /// <returns>
        /// False if the thread pool is not in the <see cref="StartStopState.Stopped"/>
        /// state, and thus cannot be started.
        /// </returns>
        protected virtual bool OnStart()
        {
            //lock other threads out of the Start function by checking/setting the state.
            lock (_startStopSyncLock)
            {
                if (_state != StartStopState.Stopped)
                {
                    return(false);
                }

                _state = StartStopState.Starting;
                EventsHelper.Fire(_startStopEvent, this, new ItemEventArgs <StartStopState>(_state));
            }

            return(true);
        }
        public StartStopState GetState(string name)
        {
            var db = new dialogTimeEntities();

            using (db)
            {
                var q = from x in db.StartStops.AsNoTracking()
                        where x.PersId == name
                        orderby x.Id descending
                        select x;
                if (q.Any())
                {
                    var first = q.First();
                    var last  = new StartStopState()
                    {
                        State          = first.TimeIntervall.EndsWith("-") ? "started" : (first.TimeIntervall.EndsWith("p") ? "paused" : "stopped"),
                        Datum          = first.Datum.Value.ToShortDateString(),
                        Projekt        = first.ProjektId.ToString(),
                        LohnKategorie  = first.LohnkategorieKuerzel,
                        TarifKategorie = first.TarifkategorieId,
                        TimeIntervall  = first.TimeIntervall,
                        Text           = first.Text
                    };
                    return(last);
                }
                else
                {
                    var last = new StartStopState()
                    {
                        State          = "stopped",
                        Datum          = null,
                        Projekt        = null,
                        LohnKategorie  = null,
                        TarifKategorie = null,
                        TimeIntervall  = "",
                        Text           = ""
                    };
                    return(last);
                }
            }
        }
예제 #5
0
		/// <summary>
		/// Default constructor.
		/// </summary>
		/// <remarks>
		/// The default number of threads in the thread pool is 1.
		/// </remarks>
		protected ThreadPoolBase()
		{
			_state = StartStopState.Stopped;
			_completeBeforeStop = false;
			_threads = new List<Thread>();
			_threadPriority = ThreadPriority.Normal;
		}
예제 #6
0
		/// <summary>
		/// Called when the thread pool has stopped.
		/// </summary>
		/// <remarks>
		/// Inheritors that override this method must ensure that the base method gets called
		/// in order for the thread pool to function correctly.
		/// </remarks>
		protected virtual void OnStopped()
		{
			lock (_startStopSyncLock)
			{
				_state = StartStopState.Stopped;
				EventsHelper.Fire(_startStopEvent, this, new ItemEventArgs<StartStopState>(_state));
			}
		}
예제 #7
0
		/// <summary>
		/// Called before the thread pool is stopped.
		/// </summary>
		/// <remarks>
		/// Inheritors that override this method must first call the base method and 
		/// cannot return true if the base method returns false.
		/// </remarks>
		/// <returns>
		/// False if the thread pool is not in the <see cref="StartStopState.Started"/> 
		/// state, and thus cannot be stopped.
		/// </returns>
		protected virtual bool OnStop(bool completeBeforeStop)
		{
			//lock other threads out of the Stop function by checking/setting the state.
			lock (_startStopSyncLock)
			{
				if (_state != StartStopState.Started)
					return false;

				_completeBeforeStop = completeBeforeStop;
				_state = StartStopState.Stopping;
				EventsHelper.Fire(_startStopEvent, this, new ItemEventArgs<StartStopState>(_state));
			}
			
			return true;
		}
예제 #8
0
 public static string StartStopOf(StartStopState level)
 {
     return string.Concat(StartStop, "-", level.ToString());
 }
예제 #9
0
 public static string StartStopOf(StartStopState level)
 {
     return(string.Concat(StartStop, "-", level.ToString()));
 }