11.07.2015 Views

y - Net Developer

y - Net Developer

y - Net Developer

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

amrameshreddy.blog.com202 CHAPTER 6 ■ MANAGING WCF SERVICESramrameshreddy.blog.com}while (true){try{foreach (string name in names){string condition = string.Format("SELECT * FROMService WHERE Name=\"{0}\"", name);SelectQuery query = new SelectQuery(condition);ManagementScope managementScope = newManagementScope(@"\\.\root\ServiceModel",new ConnectionOptions());ManagementObjectSearcher searcher = newManagementObjectSearcher(managementScope, query);ManagementObjectCollection instances = searcher.Get();foreach (ManagementBaseObject instance in instances){PropertyData data = instance.Properties["CounterInstanceName"];break;}}break;}catch(COMException){}this.totalCounter = new PerformanceCounter(CounterCategoryName, TotalCounterName,data.Value.ToString());this.totalCounter.ReadOnly = false;this.totalCounter.RawValue = 0;this.microsoftCounter = new PerformanceCounter(CounterCategoryName, MicrosoftCounterName,data.Value.ToString());this.microsoftCounter.ReadOnly = false;this.microsoftCounter.RawValue = 0;ramrameshreddyramrameshreddy}Console.WriteLine("Counters initialized.");In this code, you use a Windows Management Instrumentation Query Language (WQL)query to select the counters that are available to the runtime. Therefore, the query at runtime

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!