12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- using System.Threading.Tasks;
- namespace monitor_main_windows
- {
- public class TimedData<Data_type>
- {
- private Data_type m_data;
- private DateTime m_time_point;
- private double m_time_out_ms = 3000;
- private object m_lock = new object();
- public TimedData(Data_type data)
- {
- m_data = data;
- m_time_point = DateTime.Now;
- }
- public static implicit operator TimedData<Data_type>(Data_type data)
- {
-
- return new TimedData<Data_type>(data);
- }
- public bool IsTimeout()
- {
- DateTime time = DateTime.Now;
- if((time-m_time_point).TotalMilliseconds> m_time_out_ms)
- {
- return true;
- }
- return false;
- }
- public Data_type Value
- {
- get
- {
- return m_data;
- }
- }
- public void Set_timeout_ms(int ms=1000)
- {
- lock (m_lock)
- {
- m_time_out_ms = ms;
- }
- }
- }
- }
|