2 using System.Collections.Generic;
4 using System.Threading;
5 using System.ComponentModel;
22 private int _updateRate = 3000;
43 if (_backgroundUpdater == null)
46 _backgroundUpdater =
new BackgroundWorker();
47 _backgroundUpdater.DoWork +=
new DoWorkEventHandler(backgroundUpdater_DoWork);
48 _backgroundUpdater.RunWorkerCompleted +=
new RunWorkerCompletedEventHandler(backgroundUpdater_RunWorkerCompleted);
57 if (_updateCallBack == null && _updateTimer == null)
59 _updateCallBack =
new TimerCallback(updateTimer_Tick);
60 _updateTimer =
new Timer(_updateCallBack, null, 0, _updateRate);
69 if (_updateTimer != null)
71 _updateTimer.Change(System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite);
80 if (_updateTimer != null)
82 _updateTimer.Change(0, _updateRate);
96 if (!_backgroundUpdater.IsBusy)
98 _backgroundUpdater.RunWorkerAsync();
101 catch (Exception err)
103 Seci.Helpers.ErrorLogger.SeciError(
"LvmqUpdater:updateTimer_Tick", err);
120 if (OnLabviewNotThere != null)
122 OnLabviewNotThere(sender, e);
127 _messagesChanged = Standard.MessageQueue.UpdateMessages();
133 Seci.Helpers.ErrorLogger.SeciError(
"LvmqUpdater:backgroundUpdater_DoWork", err);
146 if (_messagesChanged && OnChangeToLVMessages != null)
148 OnChangeToLVMessages(sender, e);
153 #region IDisposable Members
166 GC.SuppressFinalize(
this);
177 protected virtual void Dispose(
bool disposing)
182 if (_backgroundUpdater != null) _backgroundUpdater.Dispose();
183 if (_updateTimer != null) _updateTimer.Dispose();
186 _backgroundUpdater = null;
void updateTimer_Tick(object obj)
The method that is called when the timer ticks. If the BackgroundWorker thread is not busy it will re...
EventHandler OnChangeToLVMessages
Event for indicating to the GUI level that the values were updated.
This class contains the DCOM connection to the LabVIEW application and stores a reference to all the ...
This class is used for checking to see if the LabVIEW messages received from the message panel VI hav...
LvmqUpdater(int updateRate)
Constructor. Initialises the BackgroundWorker object.
BackgroundWorker _backgroundUpdater
TimerCallback _updateCallBack
static Boolean AreYouThere()
void backgroundUpdater_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
The method that is run on the BackgroundWorker thread.
void PauseUpdater()
Method for pausing the timer. This is done by setting the delay and period to infinity.
EventHandler OnLabviewNotThere
void StartUpdater()
Method for starting the timer that fires off the update thread.
void ResumeUpdater()
Method for resuming the timer. This is done by setting the delay and period to their normal values...
void backgroundUpdater_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
The method that is run once the BackgroundWorker thread is finished. This raises an OnChangeToLVMessa...
void Dispose()
The dispose method to be called from code.
virtual void Dispose(bool disposing)
If the value passed it true then the method has been called directly or indirectly from SECI code...