标签:sealed sea form object action date last monit class
30.3.2 Monitor类和同步块
internal sealed class Transaction { private readonly object _lock = new object(); private DateTime _timeOfLastTrans; public void PerformTransaction() { Monitor.Enter(_lock); //数据拥有对数据的独占访问权 _timeOfLastTrans = DateTime.Now; Monitor.Exit(_lock); } public DateTime LastTransaction { get { Monitor.Enter(_lock); //数据拥有对数据的独占访问权 DateTime temp = _timeOfLastTrans; Monitor.Exit(_lock); return temp; } } }
标签:sealed sea form object action date last monit class
原文地址:https://www.cnblogs.com/kikyoqiang/p/10229360.html