/// <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; }
/// <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)); } }
/// <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); } } }
/// <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; }
/// <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)); } }
/// <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; }
public static string StartStopOf(StartStopState level) { return string.Concat(StartStop, "-", level.ToString()); }
public static string StartStopOf(StartStopState level) { return(string.Concat(StartStop, "-", level.ToString())); }