private void PollForTestWorkMessages(IAsyncResult asyncResult) { Message response = null; Message message = null; try { DataServiceContext asynchConnector = asyncResult.AsyncState as DataServiceContext; IEnumerable <Message> messages = asynchConnector.EndExecute <Message>(asyncResult); message = messages.FirstOrDefault <Message>(); SignalUI("PollingStatus", "Started"); if (null != message && !processedMessages.Any <string>(pm => pm == message.MessageID.ToString())) { processedMessages.Add(message.MessageID.ToString()); #region ClaimTest //If the test is not claimed , then claim it . //if (message.TestClientID.Length == 0) //{ // ClaimTest(message); //} //if (message.TestClientID.Length > 0 && message.TestClientID == ClientID) //{ #endregion SignalUI("MQConnectionStatus", "Pass"); response = new Message(); response.WhoSentMe = "SL"; response.Method = message.Method; RemoteClient.Dispatch(message, response); //} } } catch (Exception exception) { SignalUI("TestStatus", "Failed : " + exception.StackTrace.ToString()); Message Response = new Message(); Response.Method = message.Method; Response.WhoSentMe = "SL"; PushResponseToQueue(message, Response); //DataServiceContext dsc = GetServiceContext(); //Message response2 = new Message(); //response.ReturnValue = exception.ToString(); //response.WhoSentMe = "SL"; //response.Method = message.Method; //dsc.AddObject("Messages", response2); //dsc.BeginSaveChanges(PostTestWorkRespose, dsc); } finally { } }