How to override RawValue of PerformanceCounter? -
11-28-2007
, 11:59 PM
My application needs a "UpTime" counter to track elapsed seconds since
the application is active. My preference is to record the time to
"m_activeDate" when the application turns to active; and have one
performance counter to calculate elapsed seconds by (DateTime.Now() -
m_activeDate).TotalSeconds.
However, PerformanceCounter.RawData property is not virtual. So, I
cannot make a subclass of PerformanceCounter and override this
property. I have to have my application to set the RawData every
seconds. This is not good. I believe that calculation should happen
only when performance counter is retrieved.
Is there any better way to do it?
Thanks,
-Morgan |