public virtual void Deserialize(GenericReader reader) { int version = reader.GetVersion(); switch (version) { case 0: { _Info = reader.ReadTypeCreate <ScheduleInfo>(reader) ?? new ScheduleInfo(); _Enabled = reader.ReadBool(); _Name = reader.ReadString(); _DefaultPriority = reader.ReadFlag <TimerPriority>(); if (reader.ReadBool()) { _LastGlobalTick = reader.ReadDateTime(); } if (reader.ReadBool()) { _NextGlobalTick = reader.ReadDateTime(); } Delay = reader.ReadTimeSpan(); Interval = reader.ReadTimeSpan(); } break; } Start(); }
public static Schedule CreateSchedule( string name, bool enabled = true, bool register = true, ScheduleInfo info = null, Action <Schedule> handler = null) { return(CreateSchedule <Schedule>(name, enabled, register, info, handler)); }
public virtual void Deserialize(GenericReader reader) { var version = reader.GetVersion(); if (version > 2) { UID = new CryptoHashCode(reader); } else { UID = new CryptoHashCode(CryptoHashType.MD5, TimeStamp.Now + "+" + Utility.RandomDouble()); } switch (version) { case 3: case 2: case 1: case 0: { if (version < 2) { _Info = reader.ReadTypeCreate <ScheduleInfo>(reader) ?? new ScheduleInfo(); } else { _Info = reader.ReadBlock(r => r.ReadTypeCreate <ScheduleInfo>(r)) ?? new ScheduleInfo(); } _Enabled = reader.ReadBool(); _Name = reader.ReadString(); _DefaultPriority = reader.ReadFlag <TimerPriority>(); if (reader.ReadBool()) { _LastGlobalTick = reader.ReadDateTime(); } if (reader.ReadBool()) { _NextGlobalTick = reader.ReadDateTime(); } Delay = reader.ReadTimeSpan(); Interval = reader.ReadTimeSpan(); } break; } InvalidateNextTick(); if (version > 0) { Running = reader.ReadBool(); } }
public static TSchedule CreateSchedule <TSchedule>( string name, bool enabled = true, bool register = true, ScheduleInfo info = null, Action <Schedule> handler = null) where TSchedule : Schedule { var st = VitaNexCore.TryCatchGet(() => typeof(TSchedule).CreateInstance <TSchedule>(name, enabled, info, handler)); if (st != null && register) { st.Register(); } return(st); }
public Schedule(string name, bool enabled, ScheduleInfo info, Action <Schedule> onTick = null) : base(TimeSpan.Zero, TimeSpan.FromSeconds(1.0)) { _Enabled = enabled; _Name = name; _Info = info; UpdateTicks(DateTime.UtcNow); if (onTick != null) { OnGlobalTick += onTick; } Start(); }
public virtual void Deserialize(GenericReader reader) { var version = reader.GetVersion(); switch (version) { case 2: case 1: case 0: { if (version < 2) { _Info = reader.ReadTypeCreate <ScheduleInfo>(reader) ?? new ScheduleInfo(); } else { reader.ReadBlock(r => _Info = r.ReadTypeCreate <ScheduleInfo>(r) ?? new ScheduleInfo()); } _Enabled = reader.ReadBool(); _Name = reader.ReadString(); _DefaultPriority = reader.ReadFlag <TimerPriority>(); if (reader.ReadBool()) { _LastGlobalTick = reader.ReadDateTime(); } if (reader.ReadBool()) { _NextGlobalTick = reader.ReadDateTime(); } Delay = reader.ReadTimeSpan(); Interval = reader.ReadTimeSpan(); } break; } if (version > 0) { Running = reader.ReadBool(); } }
public Schedule(string name, bool enabled, ScheduleInfo info, params Action <Schedule>[] onTick) : base(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0)) { _Enabled = enabled; _Name = name ?? String.Empty; _Info = info ?? new ScheduleInfo(); UpdateTicks(DateTime.UtcNow); if (onTick != null) { foreach (var a in onTick) { OnGlobalTick += a; } } Start(); }
public Schedule(string name, bool enabled, ScheduleInfo info, params Action <Schedule>[] onTick) : base(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0)) { UID = new CryptoHashCode(CryptoHashType.MD5, TimeStamp.Now + "+" + Utility.RandomDouble()); _Enabled = enabled; _Name = name ?? String.Empty; _Info = info ?? new ScheduleInfo(); Instances.Add(this); UpdateTicks(Now); if (onTick != null) { foreach (var a in onTick) { OnGlobalTick += a; } } Start(); }
public virtual void Deserialize(GenericReader reader) { var version = reader.GetVersion(); switch (version) { case 2: case 1: case 0: { if (version < 2) { _Info = reader.ReadTypeCreate<ScheduleInfo>(reader) ?? new ScheduleInfo(); } else { reader.ReadBlock(r => _Info = r.ReadTypeCreate<ScheduleInfo>(r) ?? new ScheduleInfo()); } _Enabled = reader.ReadBool(); _Name = reader.ReadString(); _DefaultPriority = reader.ReadFlag<TimerPriority>(); if (reader.ReadBool()) { _LastGlobalTick = reader.ReadDateTime(); } if (reader.ReadBool()) { _NextGlobalTick = reader.ReadDateTime(); } Delay = reader.ReadTimeSpan(); Interval = reader.ReadTimeSpan(); } break; } if (version > 0) { Running = reader.ReadBool(); } }
public Schedule(string name, bool enabled, ScheduleInfo info, params Action<Schedule>[] onTick) : base(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0)) { _Enabled = enabled; _Name = name ?? String.Empty; _Info = info ?? new ScheduleInfo(); UpdateTicks(DateTime.UtcNow); if (onTick != null) { foreach (var a in onTick) { OnGlobalTick += a; } } Start(); }
public virtual void Deserialize(GenericReader reader) { int version = reader.GetVersion(); switch (version) { case 1: case 0: { _Info = reader.ReadTypeCreate<ScheduleInfo>(reader) ?? new ScheduleInfo(reader); _Enabled = reader.ReadBool(); _Name = reader.ReadString(); _DefaultPriority = reader.ReadFlag<TimerPriority>(); if (reader.ReadBool()) { _LastGlobalTick = reader.ReadDateTime(); } if (reader.ReadBool()) { _NextGlobalTick = reader.ReadDateTime(); } Delay = reader.ReadTimeSpan(); Interval = reader.ReadTimeSpan(); } break; } if (version < 1) { return; } if (reader.ReadBool() && _Enabled) { Running = true; } }
public Schedule(string name, bool enabled, ScheduleInfo info, Action<Schedule> onTick = null) : base(TimeSpan.Zero, TimeSpan.FromSeconds(1.0)) { _Enabled = enabled; _Name = name; _Info = info; UpdateTicks(DateTime.UtcNow); if (onTick != null) { OnGlobalTick += onTick; } Start(); }