Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Diagnostics / PerformanceCountersBase.cs / 1 / PerformanceCountersBase.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.ServiceModel.Diagnostics { using System.Diagnostics; using System.ServiceModel.Diagnostics; using System.Runtime.InteropServices; using System.Globalization; internal abstract class PerformanceCountersBase { internal abstract PerformanceCounter[] Counters { get; set; } internal abstract string InstanceName { get; } internal abstract string[] CounterNames { get; } internal abstract int PerfCounterStart { get; } internal abstract int PerfCounterEnd { get; } internal void Increment(int counterIndex) { PerformanceCounter[] counters = this.Counters; PerformanceCounter counter = null; try { if (counters != null) { counter = counters[counterIndex]; if (counter != null) { counter.Increment(); } } } #pragma warning suppress 56500 // covered by FxCOP catch (Exception e) { if (DiagnosticUtility.IsFatal(e)) throw; PerformanceCounters.TracePerformanceCounterUpdateFailure(this.InstanceName, this.CounterNames[counterIndex]); if (counters != null) { counters[counterIndex] = null; PerformanceCounters.ReleasePerformanceCounter(ref counter); } } } internal void IncrementBy(int counterIndex, long time) { PerformanceCounter[] counters = this.Counters; PerformanceCounter counter = null; try { if (counters != null) { counter = counters[counterIndex]; if (counter != null) { counter.IncrementBy(time); } } } #pragma warning suppress 56500 // covered by FxCOP catch (Exception e) { if (DiagnosticUtility.IsFatal(e)) throw; PerformanceCounters.TracePerformanceCounterUpdateFailure(this.InstanceName, this.CounterNames[counterIndex]); if (counters != null) { counters[counterIndex] = null; PerformanceCounters.ReleasePerformanceCounter(ref counter); } } } internal void Decrement(int counterIndex) { PerformanceCounter[] counters = this.Counters; PerformanceCounter counter = null; try { if (counters != null) { counter = counters[counterIndex]; if (counter != null) { counter.Decrement(); } } } #pragma warning suppress 56500 // covered by FxCOP catch (Exception e) { if (DiagnosticUtility.IsFatal(e)) throw; PerformanceCounters.TracePerformanceCounterUpdateFailure(this.InstanceName, this.CounterNames[counterIndex]); if (counters != null) { counters[counterIndex] = null; PerformanceCounters.ReleasePerformanceCounter(ref counter); } } } // remove count chars from string and add a 2 char hash code to beginning or end, as specified. protected static string GetHashedString(string str, int startIndex, int count, bool hashAtEnd) { string returnVal = str.Remove(startIndex, count); string hash = ((uint)str.GetHashCode() % 99).ToString("00", CultureInfo.InvariantCulture); return hashAtEnd ? returnVal + hash : hash + returnVal; } internal void ReleasePerformanceCounters() { if (PerformanceCounters.PerformanceCountersEnabled) { PerformanceCounter[] counters = this.Counters; this.Counters = null; if (null != counters) { for (int ctr = this.PerfCounterStart; ctr < this.PerfCounterEnd; ++ctr) { PerformanceCounter counter = counters[ctr]; if (counter != null) { PerformanceCounters.ReleasePerformanceCounter(ref counter); } counters[ctr] = null; } } } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- SupportsEventValidationAttribute.cs
- GenerateTemporaryTargetAssembly.cs
- PtsPage.cs
- MenuAdapter.cs
- FileDialogCustomPlace.cs
- Number.cs
- EntryPointNotFoundException.cs
- DependencyObjectCodeDomSerializer.cs
- ResourceIDHelper.cs
- MachineSettingsSection.cs
- Brush.cs
- IgnoreSectionHandler.cs
- SmtpSection.cs
- PersonalizationState.cs
- OracleConnection.cs
- SiteMapNodeItem.cs
- milexports.cs
- Int64KeyFrameCollection.cs
- coordinatorfactory.cs
- MergePropertyDescriptor.cs
- SiteMapNode.cs
- SeverityFilter.cs
- XmlNamedNodeMap.cs
- RoleGroupCollection.cs
- EditingCommands.cs
- SignerInfo.cs
- BackStopAuthenticationModule.cs
- DataGridTablesFactory.cs
- EntityChangedParams.cs
- WizardForm.cs
- ToolStripDropDownItem.cs
- Label.cs
- RoleServiceManager.cs
- SweepDirectionValidation.cs
- Clause.cs
- XmlSchemaComplexType.cs
- GraphicsContainer.cs
- Blend.cs
- EntitySetBaseCollection.cs
- Matrix3DConverter.cs
- AssemblyUtil.cs
- X509CertificateClaimSet.cs
- CheckBox.cs
- SqlWriter.cs
- SafeEventLogWriteHandle.cs
- DebuggerAttributes.cs
- ConfigurationLocation.cs
- ColorContext.cs
- SignatureGenerator.cs
- SizeChangedInfo.cs
- SiteMapDesignerDataSourceView.cs
- EntityContainerEmitter.cs
- Size.cs
- OLEDB_Util.cs
- objectquery_tresulttype.cs
- ListViewGroup.cs
- Enlistment.cs
- GridSplitter.cs
- EventLogEntryCollection.cs
- Scanner.cs
- BatchWriter.cs
- EmptyEnumerator.cs
- ToolboxItemFilterAttribute.cs
- CharacterShapingProperties.cs
- PriorityQueue.cs
- FrameworkRichTextComposition.cs
- DbQueryCommandTree.cs
- WebPartDisplayMode.cs
- UnsafeNativeMethodsMilCoreApi.cs
- SessionParameter.cs
- ClosureBinding.cs
- ContextProperty.cs
- handlecollector.cs
- EventTrigger.cs
- AsyncPostBackTrigger.cs
- WebBaseEventKeyComparer.cs
- XmlWrappingReader.cs
- NodeLabelEditEvent.cs
- XmlnsCache.cs
- XslNumber.cs
- ParsedAttributeCollection.cs
- DataGridViewColumnHeaderCell.cs
- TextEditorThreadLocalStore.cs
- MembershipUser.cs
- UnmanagedHandle.cs
- SQLString.cs
- ContentValidator.cs
- FlowDocumentView.cs
- GridItemPattern.cs
- MimeParameterWriter.cs
- UriWriter.cs
- Delegate.cs
- TypeSystemProvider.cs
- WorkflowWebService.cs
- XPathLexer.cs
- PolyBezierSegmentFigureLogic.cs
- userdatakeys.cs
- StrongTypingException.cs
- DelegatingChannelListener.cs
- FunctionMappingTranslator.cs