public async Task Awake(object state) { if (false == AwakeServices.Count() > 0) { return; } foreach (var service in AwakeServices) { await service.Awake(state); } }
void InitializeIfEnabled(Assembly[] awakerAssemblies) { if (false == awakerAssemblies?.Count() > 0) { return; } foreach (var asm in awakerAssemblies) { var types = from type in asm.GetTypes() where typeof(IPleaseAwakeMyselfService).IsAssignableFrom(type) select type; foreach (var t in types) { IPleaseAwakeMyselfService instance = (IPleaseAwakeMyselfService)(Activator.CreateInstance(t, Configuration, Serializer)); AwakeServices.Add(instance); } } var delay = Option.DelayStartInSecs * 1000; if (delay <= 1) { delay = 1000; } var period = Option.PeriodInSecs * 1000; if (period <= 1) { period = 1000; } JobTimer = new Timer( new TimerCallback(async(o) => await Awake(o)), null, delay, period); }