Files
mono/mcs/class/referencesource/System.ServiceModel/System/ServiceModel/Diagnostics/SystemDiagnosticsPerformanceCountersExtension.cs
dotnet-bot adf899c629 Adding System.Data..., System.ServiceModel..., and System.Web...
Adding reference source for
System.Data
System.Data.DataSetExtensions
System.Data.Entity
System.Data.Entity.Design
System.Data.Linq
System.Data.SqlXml
System.ServiceModel
System.ServiceModel.Activation
System.ServiceModel.Activities
System.ServiceModel.Channels
System.ServiceModel.Discovery
System.ServiceModel.Internals
System.ServiceModel.Routing
System.ServiceModel.WasHosting
System.ServiceModel.Web
System.Web
System.Web.ApplicationServices
System.Web.DynamicData
System.Web.Entity
System.Web.Entity.Design
System.Web.Extensions
System.Web.Mobile
System.Web.Routing
System.Web.Services
System.Xml
System.Xml.Linq
2016-05-03 00:07:37 +02:00

118 lines
4.2 KiB
C#

//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.ServiceModel.Diagnostics
{
using System.Diagnostics;
using System.Runtime;
static class SystemDiagnosticsPerformanceCountersExtension
{
static internal void Increment(this PerformanceCountersBase thisPtr, PerformanceCounter[] counters, int counterIndex)
{
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 (Fx.IsFatal(e)) throw;
PerformanceCounters.TracePerformanceCounterUpdateFailure(thisPtr.InstanceName, thisPtr.CounterNames[counterIndex]);
if (counters != null)
{
counters[counterIndex] = null;
PerformanceCounters.ReleasePerformanceCounter(ref counter);
}
}
}
static internal void IncrementBy(this PerformanceCountersBase thisPtr, PerformanceCounter[] counters, int counterIndex, long time)
{
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 (Fx.IsFatal(e)) throw;
PerformanceCounters.TracePerformanceCounterUpdateFailure(thisPtr.InstanceName, thisPtr.CounterNames[counterIndex]);
if (counters != null)
{
counters[counterIndex] = null;
PerformanceCounters.ReleasePerformanceCounter(ref counter);
}
}
}
static internal void Set(this PerformanceCountersBase thisPtr, PerformanceCounter[] counters, int counterIndex, long value)
{
PerformanceCounter counter = null;
try
{
if (counters != null)
{
counter = counters[counterIndex];
if (counter != null)
{
counter.RawValue = value;
}
}
}
#pragma warning suppress 56500 // covered by FxCOP
catch (Exception e)
{
if (Fx.IsFatal(e)) throw;
PerformanceCounters.TracePerformanceCounterUpdateFailure(thisPtr.InstanceName, thisPtr.CounterNames[counterIndex]);
counters[counterIndex] = null;
PerformanceCounters.ReleasePerformanceCounter(ref counter);
}
}
static internal void Decrement(this PerformanceCountersBase thisPtr, PerformanceCounter[] counters, int counterIndex)
{
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 (Fx.IsFatal(e)) throw;
PerformanceCounters.TracePerformanceCounterUpdateFailure(thisPtr.InstanceName, thisPtr.CounterNames[counterIndex]);
if (counters != null)
{
counters[counterIndex] = null;
PerformanceCounters.ReleasePerformanceCounter(ref counter);
}
}
}
}
}