private void WaitAndProcessProbeResponses(MapiFolder folder, string fromAddress, Dictionary <string, string> subjectTargets, ExDateTime probeSentTime)
        {
            List <byte[]> list  = new List <byte[]>();
            List <string> list2 = new List <string>();

            for (int i = 0; i < base.Task.ExecutionTimeout; i++)
            {
                foreach (KeyValuePair <string, string> keyValuePair in subjectTargets)
                {
                    if (!string.IsNullOrEmpty(keyValuePair.Value))
                    {
                        using (MapiMessage deliveryReceipt = TestMailFlowHelper.GetDeliveryReceipt(folder, keyValuePair.Key, false))
                        {
                            if (deliveryReceipt != null)
                            {
                                PropValue prop  = deliveryReceipt.GetProp(PropTag.MessageDeliveryTime);
                                PropValue prop2 = deliveryReceipt.GetProp(PropTag.EntryId);
                                PropValue prop3 = deliveryReceipt.GetProp(PropTag.Subject);
                                if (!prop.IsError() && prop.Value != null && prop3.Value != null)
                                {
                                    string text = prop3.Value.ToString();
                                    if (text.StartsWith("RSP: CrossPremiseMailFlowMonitoring-", StringComparison.OrdinalIgnoreCase))
                                    {
                                        EnhancedTimeSpan latency = ((ExDateTime)prop.GetDateTime() > probeSentTime) ? ((ExDateTime)prop.GetDateTime() - probeSentTime) : EnhancedTimeSpan.Zero;
                                        base.OutputResult(Strings.TestMailflowSucceeded(fromAddress, keyValuePair.Value), latency, base.IsRemoteTest);
                                    }
                                    else if (text.StartsWith("Undeliverable: CrossPremiseMailFlowMonitoring-", StringComparison.OrdinalIgnoreCase))
                                    {
                                        EnhancedTimeSpan latency2 = EnhancedTimeSpan.FromSeconds(0.0);
                                        string           info     = (string)deliveryReceipt.GetProp(PropTag.Body).Value;
                                        base.OutputResult(Strings.CrossPremiseProbeNdred(fromAddress, keyValuePair.Value, info), latency2, base.IsRemoteTest);
                                    }
                                    list2.Add(keyValuePair.Key);
                                    list.Add(prop2.GetBytes());
                                }
                            }
                        }
                    }
                }
                foreach (string key in list2)
                {
                    subjectTargets.Remove(key);
                }
                list2.Clear();
                if (subjectTargets.Count == 0)
                {
                    break;
                }
                Thread.Sleep(1000);
            }
            foreach (KeyValuePair <string, string> keyValuePair2 in subjectTargets)
            {
                if (!string.IsNullOrEmpty(keyValuePair2.Value))
                {
                    EnhancedTimeSpan latency3 = EnhancedTimeSpan.FromSeconds(0.0);
                    base.OutputResult(Strings.MapiTransactionResultFailure, latency3, base.IsRemoteTest);
                }
            }
            folder.DeleteMessages(DeleteMessagesFlags.ForceHardDelete, list.ToArray());
        }
        private MapiMessage WaitForDeliveryReceipt(MapiFolder folder, string subject, int errorLatency, int timeoutSeconds, string sourceAddress, string targetAddress)
        {
            bool        flag        = false;
            MapiMessage mapiMessage = null;

            for (int i = 0; i < timeoutSeconds; i++)
            {
                mapiMessage = TestMailFlowHelper.GetDeliveryReceipt(folder, subject, true);
                if (mapiMessage != null)
                {
                    break;
                }
                Thread.Sleep(1000);
                if (!flag && i >= errorLatency)
                {
                    flag = true;
                    base.AddErrorMonitoringEvent(1002, Strings.TestMailflowError(sourceAddress, targetAddress, errorLatency));
                }
            }
            return(mapiMessage);
        }