/// <summary> /// Timer callback delegate. /// </summary> /// <param name="state">The state.</param> private void TimerCallback(object state) { // Every second alternately publish one of our two event types. ISignalREvent myEvent; if (_flip) { myEvent = new SimpleEvent { MessageText = string.Format("Server says hi at {0}", DateTime.Now) }; } else { var employee = new Employee { Name = "John Smith", BirthDate = DateTime.Today }; myEvent = new ComplexEvent { Employee = employee, Timestamp = DateTime.Now }; } // Publish the event via Prism's event aggregator (horrible syntax!) _prismEventAggregator.GetEvent<PubSubEvent<ISignalREvent>>().Publish(myEvent); _flip = !_flip; }
/// <summary> /// Event subscriber delegate. Simply outputs details of the received events to the console. /// </summary> /// <param name="complexEvent">The event.</param> private static void ComplexEventSubscriber(ComplexEvent complexEvent) { Console.WriteLine("Complex event. Employee: {0} {1}", complexEvent.Employee.Name, complexEvent.Employee.BirthDate); Console.WriteLine(" Timestamp: {0}", complexEvent.Timestamp); Console.WriteLine(); }