public void StartThread() { try { if (isthreadrunning) { mTimer1.Stop(); timerthread.Abort(); } timerthread = new Thread(t => { mTimer1 = new AccurateTimer(this, new Action(TimerTick1), intervalms); }) { IsBackground = true }; timerthread.Start(); timerthread.Priority = ThreadPriority.Highest; isthreadrunning = true; RecordLog("1.2 Timerthread started interval:" + intervalms); } catch (Exception ex) { RecordLog(ex.Message); } }
public void StartThread() { try { util.RecordLog(connectionstr, "1.2 Thread paramaeter check , interval:" + intervalms + " isthreadrunning " + isthreadrunning, util.INFO); if (isthreadrunning)//Stop current thread, and create a new one { mTimer1.Stop(); timerthread.Abort(); isthreadrunning = false; util.RecordLog(connectionstr, "1.2 Thread aborted, ID: " + timerthread.ManagedThreadId, util.INFO); } timerthread = new Thread(t => { mTimer1 = new AccurateTimer(this, new Action(TimerTick1), intervalms); }); if (!timerthread.IsAlive) { timerthread.Priority = ThreadPriority.Highest; timerthread.IsBackground = true; timerthread.Start(); isthreadrunning = true; util.RecordLog(connectionstr, "1.2 Timerthread started interval:" + intervalms + " ID: " + timerthread.ManagedThreadId, util.INFO); } } catch (Exception ex) { util.RecordLog(connectionstr, "StartThread:" + ex.ToString(), util.ALARM); } }