コード例 #1
0
 public static void OutputMessageInfo(string action, PingData pingData)
 {
     lock (typeof(SampleManager))
     {
         Console.ForegroundColor = colors[int.Parse(pingData.SenderId)];
         Console.WriteLine("{0}: Message [{1}].", action, pingData.Message);
         Console.ResetColor();
     }
 }
コード例 #2
0
 static void SendMessages(IPingServiceContract clientChannel)
 {
     // Send messages to queue which requires session:
     for (int i = 0; i < numberOfMessages; i++)
     {
         // Send message
         PingData message = CreatePingData();
         clientChannel.Ping(message);
         SampleManager.OutputMessageInfo("Send", message);
         Thread.Sleep(200);
     }
 }
コード例 #3
0
        public void Ping(PingData pingData)
        {
            // Get the message properties
            var incomingProperties           = OperationContext.Current.IncomingMessageProperties;
            BrokeredMessageProperty property = (BrokeredMessageProperty)incomingProperties[BrokeredMessageProperty.Name];

            // Print message
            SampleManager.OutputMessageInfo("Receive", pingData);

            //Complete the Message
            ReceiveContext receiveContext;

            if (ReceiveContext.TryGet(incomingProperties, out receiveContext))
            {
                receiveContext.Complete(TimeSpan.FromSeconds(10.0d));
            }
            else
            {
                throw new InvalidOperationException("Receiver is in peek lock mode but receive context is not available!");
            }
        }