Я создал счетчик производительности в C#. Однако, назначив ему значение, я хотел бы, чтобы значение было float
вместо long
, но я не могу понять, как это сделать. Может ли кто-нибудь помочь?Назначить значение поплавка счетчику производительности
код я использую из Counter of type RateOfCountsPerSecond32 always shows 0:
public static void Test()
{
var ccdc = new CounterCreationDataCollection();
// Add the counter.
const string counterName = "RateOfCountsPerSecond64Sample";
var rateOfCounts64 = new CounterCreationData
{
CounterType = PerformanceCounterType.RateOfCountsPerSecond64,
CounterName = counterName
};
ccdc.Add(rateOfCounts64);
// Create the category.
const string categoryName = "RateOfCountsPerSecond64SampleCategory";
if (PerformanceCounterCategory.Exists(categoryName))
PerformanceCounterCategory.Delete(categoryName);
PerformanceCounterCategory.Create(categoryName, "",
PerformanceCounterCategoryType.SingleInstance, ccdc);
// create the counter
var pc = new PerformanceCounter(categoryName, counterName, false);
pc.RawValue = 1000; // <-- want to assign a float value here
}
Может кто-нибудь помочь?
RawValue - длинное свойство, так почему вы хотите присвоить значение float длинному свойству? –