public ClassBenchmark(string Mailbox, ExchangeCredentials Credentials, ClassStats Stats, ClassLogger Logger, string EWSUrl = "")
        {
            _service = new ExchangeService(ExchangeVersion.Exchange2013_SP1);
            ServicePointManager.ServerCertificateValidationCallback = ValidateCertificate;
            _service.Credentials = Credentials;
            _mailbox             = Mailbox;
            _stats  = Stats;
            _logger = Logger;
            long startTicks = DateTime.Now.Ticks;

            if (!String.IsNullOrEmpty(EWSUrl))
            {
                _logger.Log($"Using EWS URL: {EWSUrl}");
                _service.Url = new Uri(EWSUrl);
            }
            else
            {
                _logger.Log(String.Format("Performing autodiscover for {0}", Mailbox));
                try
                {
                    _service.AutodiscoverUrl(Mailbox, AutodiscoverCallback);
                }
                catch (Exception ex)
                {
                    _logger.Log(String.Format("Autodiscover failed: {0}", ex.Message));
                }
                finally
                {
                    long endTicks = DateTime.Now.Ticks;
                    Stats.AddStat("Autodiscover", endTicks - startTicks);
                }
            }
        }
 public Form1()
 {
     InitializeComponent();
     _stats              = new ClassStats();
     _stats.StatUpdated += _stats_StatUpdated;
     _logger             = new ClassLogger("EWSBenchmark.log");
     _logger.LogAdded   += _logger_LogAdded;
 }