コード例 #1
0
ファイル: Program.cs プロジェクト: jdaigle/CWServiceBus
        public static void Run()
        {
            Console.WriteLine("This will publish IEvent and EventMessage alternately.");
            Console.WriteLine("Press 'Enter' to publish a message.To exit, Ctrl + C");

            bool publishIEvent = true;

            while (Console.ReadLine() != null)
            {
                var eventMessage = publishIEvent ? MessageBus.CreateInstance <IMyEvent>() : new EventMessage();

                eventMessage.EventId  = Guid.NewGuid();
                eventMessage.Time     = DateTime.Now.Second > 30 ? (DateTime?)DateTime.Now : null;
                eventMessage.Duration = TimeSpan.FromSeconds(99999D);

                MessageBus.Publish(eventMessage);

                Console.WriteLine("Published event with Id {0}.", eventMessage.EventId);
                Console.WriteLine("==========================================================================");

                publishIEvent = !publishIEvent;
            }
        }