internal TransportClientWrapper(
                TransportClient client,
                Action <Uri, ResourceOperation, DocumentServiceRequest> interceptor,
                bool injectCpuMonitor = false)
            {
                Debug.Assert(client != null);
                Debug.Assert(interceptor != null);

                if (injectCpuMonitor)
                {
                    CpuMonitor.OverrideRefreshInterval(TimeSpan.FromMilliseconds(100));
                    this.cpuMonitor = new CpuMonitor();
                    this.cpuMonitor.Start();
                    Stopwatch watch = Stopwatch.StartNew();

                    // Artifically burning some CPU to generate CPU load history
                    CpuLoadHistory cpuLoadHistory = null;
                    while ((cpuLoadHistory = this.cpuMonitor.GetCpuLoad()) == null ||
                           cpuLoadHistory.ToString() == emptyCpuLoadHistoryText)
                    {
                        Task.Delay(10).Wait();
                    }
                }
                this.baseClient  = client;
                this.interceptor = interceptor;
            }
 public override void Dispose()
 {
     if (this.cpuMonitor != null)
     {
         this.cpuMonitor.Stop();
         CpuMonitor.OverrideRefreshInterval(
             TimeSpan.FromSeconds(CpuMonitor.DefaultRefreshIntervalInSeconds));
     }
     base.Dispose();
 }