private static void HandlePerformanceCounterUpdateException(Exception ex)
        {
            lock (syncRoot)
            {
                performanceCounter = null;
            }

            log.Error(string.Format("Exception during performance counter update. Exception Msg:{0}", ex.Message), ex);
        }
        public static void InitializePerformanceCounter(string instanceName)
        {
            lock (syncRoot)
            {
                if (performanceCounter != null)
                {
                    throw new InvalidOperationException("PerformanceCounter have allready been initialized.");
                }

                try
                {
                    PerfCounter.Initialize();
                    perfCounterInstanceName = instanceName;
                    performanceCounter      = PerfCounter.GetInstance(instanceName);
                }
                catch (Exception)
                {
                    performanceCounter = null;
                    throw;
                }
            }
        }