protected internal override void Define() { On((HasBeenReminded x) => reminded); On((SetReminder x) => Reminders.Register("test", TimeSpan.Zero, x.Period)); On((GetInstanceHashcode x) => RuntimeHelpers.GetHashCode(this)); On((Deactivate x) => Activation.DeactivateOnIdle()); }
public async Task Handle(CreateTopic cmd) { query = cmd.Query; foreach (var entry in cmd.Schedule) { await Reminders.Register(entry.Key.Path.Id, TimeSpan.Zero, entry.Value); } }
async Task <object> On(object message) { switch (message) { case Reminder _: Console.WriteLine("Reminded"); return(Done); case Activate _: await NotifyLightsOn(); return(""); case Deactivate _: await CleanupOn(); return(""); case PressSwitch _: await behavior.Become(Off); return("Turning off"); case Touch _: return("Hot!"); default: return(Unhandled); } async Task NotifyLightsOn() { await Reminders.Register("123", TimeSpan.FromSeconds(60), TimeSpan.FromSeconds(60)); Timers.Register("123", TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1), () => { Console.WriteLine("Lights, on!!!"); return(Task.CompletedTask); }); } async Task CleanupOn() { Timers.Unregister("123"); await Reminders.Unregister("123"); } }
void On(SetReminder x) => Reminders.Register("test", TimeSpan.Zero, x.Period);
Task On(RegisterReminder x) => Reminders.Register(x.Name, TimeSpan.FromHours(10), TimeSpan.FromHours(10));