public void SimulateTimer(int timer) { if (timer <= 0) { throw new ArgumentException(); } ImitationWatchEventArgs e = new ImitationWatchEventArgs(timer); e.RunTimer(); EndTimer(e); }
private void SubscriberMsg(Object sender, ImitationWatchEventArgs e) { Console.WriteLine($"I am SubscriberTwo and I waited an answer for {e.Timer} seconds!"); }
private void EndTimer(ImitationWatchEventArgs e) { ImitationWatchEventHandler alertSubscribers = Volatile.Read(ref TimeIsOver); alertSubscribers?.Invoke(this, e); }