internal void CreatePerfCounterCategory()
        {
            int num  = 0;
            int num2 = 15000;
            LoadUnloadPerfCounterLocalizedText loadUnloadPerfCounterLocalizedText = new LoadUnloadPerfCounterLocalizedText();

            TaskLogger.LogEnter();
            base.WriteVerbose(Strings.PerfCounterCategoryDefinition(this.CategoryName));
            if (!this.unmanagedCategory)
            {
                bool flag;
                do
                {
                    Exception ex = null;
                    try
                    {
                        PerformanceCounterCategory.Create(this.CategoryName, string.Empty, this.categoryType, this.counterDataCollection);
                    }
                    catch (InvalidOperationException ex2)
                    {
                        if (!PerformanceCounterCategory.Exists(this.CategoryName))
                        {
                            ex = ex2;
                        }
                    }
                    catch (Win32Exception ex3)
                    {
                        ex = ex3;
                    }
                    if (ex == null)
                    {
                        break;
                    }
                    num++;
                    flag = (num < 5);
                    if (flag)
                    {
                        base.WriteVerbose(Strings.PerfCounterFileInUse(this.CategoryName, num2 / 1000, 5 - num));
                        Thread.Sleep(num2);
                    }
                    else
                    {
                        base.WriteError(ex, ErrorCategory.InvalidData, null);
                    }
                }while (flag);
                if (this.fileMappingSize > 0)
                {
                    string name = string.Format(CultureInfo.InvariantCulture, "SYSTEM\\CurrentControlSet\\Services\\{0}\\Performance", new object[]
                    {
                        this.CategoryName
                    });
                    using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(name, true))
                    {
                        registryKey.SetValue("FileMappingSize", this.fileMappingSize);
                    }
                }
                try
                {
                    loadUnloadPerfCounterLocalizedText.UnloadLocalizedText(this.iniFileName, this.CategoryName);
                    loadUnloadPerfCounterLocalizedText.LoadLocalizedText(this.iniFileName, this.CategoryName);
                    goto IL_251;
                }
                catch (FileNotFoundException exception)
                {
                    base.WriteError(exception, ErrorCategory.InvalidData, null);
                    goto IL_251;
                }
                catch (TaskException exception2)
                {
                    base.WriteError(exception2, ErrorCategory.InvalidData, null);
                    goto IL_251;
                }
            }
            string subkey = string.Format(CultureInfo.InvariantCulture, "SYSTEM\\CurrentControlSet\\Services\\{0}\\Performance", new object[]
            {
                this.CategoryName
            });

            using (RegistryKey registryKey2 = Registry.LocalMachine.CreateSubKey(subkey))
            {
                if (this.extensionDllInfo.UseExpandedStringForLibrary)
                {
                    registryKey2.SetValue("Library", this.extensionDllInfo.Library, RegistryValueKind.ExpandString);
                }
                else
                {
                    registryKey2.SetValue("Library", this.extensionDllInfo.Library);
                }
                registryKey2.SetValue("Open", this.extensionDllInfo.Open);
                registryKey2.SetValue("Collect", this.extensionDllInfo.Collect);
                registryKey2.SetValue("Close", this.extensionDllInfo.Close);
            }
            try
            {
                loadUnloadPerfCounterLocalizedText.LoadLocalizedText(this.iniFileName, this.CategoryName);
            }
            catch (FileNotFoundException exception3)
            {
                base.WriteError(exception3, ErrorCategory.InvalidData, null);
            }
            catch (TaskException exception4)
            {
                base.WriteError(exception4, ErrorCategory.InvalidData, null);
            }
IL_251:
            TaskLogger.LogExit();
        }
        internal void DeletePerfCounterCategory()
        {
            int  num  = 0;
            bool flag = false;
            int  num2 = 15000;
            LoadUnloadPerfCounterLocalizedText loadUnloadPerfCounterLocalizedText = new LoadUnloadPerfCounterLocalizedText();

            TaskLogger.LogEnter();
            base.WriteVerbose(Strings.PerfCounterCategoryDefinition(this.CategoryName));
            if (!this.unmanagedCategory)
            {
                this.LogInstalledCategoryNames(Path.GetFullPath(this.iniFileName), "Rem");
                do
                {
                    try
                    {
                        PerformanceCounterCategory.Delete(this.CategoryName);
                    }
                    catch (Win32Exception exception)
                    {
                        num++;
                        flag = (num < 5);
                        if (flag)
                        {
                            base.WriteVerbose(Strings.PerfCounterFileInUse(this.CategoryName, num2 / 1000, 5 - num));
                            Thread.Sleep(num2);
                        }
                        else
                        {
                            base.WriteError(exception, ErrorCategory.InvalidData, null);
                        }
                    }
                    catch (InvalidOperationException exception2)
                    {
                        if (PerformanceCounterCategory.Exists(this.CategoryName))
                        {
                            base.WriteError(exception2, ErrorCategory.InvalidData, null);
                        }
                        flag = false;
                    }
                }while (flag);
            }
            else
            {
                try
                {
                    loadUnloadPerfCounterLocalizedText.UnloadLocalizedText(this.iniFileName, this.CategoryName);
                }
                catch (Win32Exception exception3)
                {
                    base.WriteError(exception3, ErrorCategory.InvalidData, null);
                }
                catch (TaskException exception4)
                {
                    base.WriteError(exception4, ErrorCategory.InvalidData, null);
                }
                string subkey = string.Format(CultureInfo.InvariantCulture, "SYSTEM\\CurrentControlSet\\Services\\{0}", new object[]
                {
                    this.CategoryName
                });
                Registry.LocalMachine.DeleteSubKeyTree(subkey);
            }
            TaskLogger.LogExit();
        }