/// <summary> /// 构造函数:指定同步间隔时间及所有数据同步的委托,只适合那种更新较快的项 /// </summary> /// <param name="GapSpan"></param> /// <param name="method"></param> internal CacheItem(TimeSpan GapSpan, Func <Dictionary <TKey, TValue> > method) { GetAllMethod = method; if (method != null) { myCacheItem = CacheItemInfoCollection <TParam, TKey, TValue> .CreateDatas(method()); } else { myCacheItem = new CacheItemInfoCollection <TParam, TKey, TValue>(); } myCacheItem.Owner = this; syncUtil = ThreadSvrUtil.CreateSvrUtil(GapSpan, SyncData); //自动启动同步服务 syncUtil.Start(); }
/// <summary> /// 构造函数:指定同步间隔时间及所有数据同步的委托,只适合那种更新较快的项 /// 通过定时表达式创建定时激活器 /// 定时器设置格式如下: /// 1、定时触发:0|h|1,表示按每小时激活,0|m|1 表示按每分钟激活,0|s|1 表示按每秒钟激活,0|ms|1 表示按每毫秒激活 /// 2、时点触发:1|17:30;17:12;02:36 /// </summary> /// <param name="GapSpanExp"></param> /// <returns></returns> internal CacheItem(string GapSpanExp, Func <Dictionary <TKey, TValue> > method, Dictionary <TKey, TValue> items) { GetAllMethod = method; if (items != null) { myCacheItem = CacheItemInfoCollection <TParam, TKey, TValue> .CreateDatas(items); } else { myCacheItem = new CacheItemInfoCollection <TParam, TKey, TValue>(); } myCacheItem.Owner = this; ThreadTimer timer = ThreadTimer.CreateThreadTimerByExp(GapSpanExp); timer.Method = SyncData; syncUtil = new ThreadSvrUtil(timer); //自动启动同步服务 syncUtil.Start(); }