Пример #1
0
        private Task SendAndExpect(ControlMessage messageToSend, BreweryMessageType responseExpected, int timeoutInSeconds)
        {
            DateTime timeoutAt   = DateTime.Now + TimeSpan.FromSeconds(timeoutInSeconds);
            long     firstSendAt = m_stopwatch.ElapsedTicks;

            return(Task.Run(() =>
            {
                while (timeoutInSeconds == -1 || DateTime.Now < timeoutAt)
                {
                    NetworkPump.Send(messageToSend);
                    System.Threading.Thread.Sleep(1000);

                    long ts = 0;
                    if (m_receiptStamps.TryGetValue(responseExpected, out ts))
                    {
                        if (ts >= firstSendAt)
                        {
                            break;
                        }
                    }
                }
            }));
        }
Пример #2
0
 private Task SendAndExpect(ControlMessage messageToSend, BreweryMessageType responseExpected)
 {
     return(SendAndExpect(messageToSend, responseExpected, NetworkTimeout));
 }
Пример #3
0
 internal static Type GetMessageType(BreweryMessageType type)
 {
     return(EnumTypeToObjectType[type]);
 }