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
- AttachInfo.cs
- ReflectPropertyDescriptor.cs
- NetTcpSecurityElement.cs
- TextTreePropertyUndoUnit.cs
- InboundActivityHelper.cs
- DecimalAnimation.cs
- HostingEnvironment.cs
- ObfuscationAttribute.cs
- PnrpPermission.cs
- PerfService.cs
- DropShadowBitmapEffect.cs
- FocusWithinProperty.cs
- TaskFactory.cs
- CodeTypeMember.cs
- ProfileGroupSettingsCollection.cs
- TransactedBatchingElement.cs
- MetabaseReader.cs
- BaseDataList.cs
- MemberProjectionIndex.cs
- InvariantComparer.cs
- CodeMemberEvent.cs
- HandledEventArgs.cs
- SemaphoreSecurity.cs
- ConnectionInterfaceCollection.cs
- FileDetails.cs
- GeneralTransform3DGroup.cs
- UTF8Encoding.cs
- GcSettings.cs
- Size3DConverter.cs
- DataGridParentRows.cs
- ContextMenuStrip.cs
- BindingMemberInfo.cs
- PropertyIDSet.cs
- AuthenticateEventArgs.cs
- ExchangeUtilities.cs
- LifetimeServices.cs
- TextServicesContext.cs
- TextTreeExtractElementUndoUnit.cs
- cookieexception.cs
- infer.cs
- HitTestDrawingContextWalker.cs
- TraceSource.cs
- ListViewVirtualItemsSelectionRangeChangedEvent.cs
- BitmapEffectInput.cs
- ImageAnimator.cs
- StaticTextPointer.cs
- PointCollectionConverter.cs
- ProxyManager.cs
- AssemblyHelper.cs
- BasicKeyConstraint.cs
- OrthographicCamera.cs
- ObjectDataSourceEventArgs.cs
- SqlException.cs
- ReadOnlyDataSourceView.cs
- UnsafeNativeMethods.cs
- SqlFunctionAttribute.cs
- WebBrowserBase.cs
- Point4DConverter.cs
- ActivitiesCollection.cs
- ParameterInfo.cs
- TempEnvironment.cs
- DataGridViewDataErrorEventArgs.cs
- TraceData.cs
- VisualTreeHelper.cs
- SharedStream.cs
- NameSpaceExtractor.cs
- ColorConverter.cs
- ModelUIElement3D.cs
- HtmlInputPassword.cs
- XmlAttributeProperties.cs
- ClipboardData.cs
- OptimizedTemplateContent.cs
- WebPartMinimizeVerb.cs
- MessageQueueCriteria.cs
- KeyPressEvent.cs
- TextRangeAdaptor.cs
- ToolStripLabel.cs
- RequestResizeEvent.cs
- UnaryNode.cs
- DataControlFieldCollection.cs
- RepeaterItem.cs
- CompareInfo.cs
- DynamicDocumentPaginator.cs
- IUnknownConstantAttribute.cs
- CalloutQueueItem.cs
- StrokeIntersection.cs
- Popup.cs
- EditCommandColumn.cs
- SerializationInfoEnumerator.cs
- FormViewUpdateEventArgs.cs
- MergablePropertyAttribute.cs
- Point3DAnimationBase.cs
- ExpressionCopier.cs
- HMAC.cs
- SmiRequestExecutor.cs
- ProfileEventArgs.cs
- ReceiveMessageContent.cs
- CodeMethodInvokeExpression.cs
- Rect.cs
- FieldDescriptor.cs