Click here to Skip to main content
15,887,821 members
Home / Discussions / C#
   

C#

 
GeneralRe: Reading and storing application settings in an object at startup Pin
Member 115846887-Apr-15 4:57
Member 115846887-Apr-15 4:57 
GeneralRe: Reading and storing application settings in an object at startup Pin
Gerry Schmitz7-Apr-15 9:06
mveGerry Schmitz7-Apr-15 9:06 
GeneralRe: Reading and storing application settings in an object at startup Pin
Member 115846887-Apr-15 8:54
Member 115846887-Apr-15 8:54 
GeneralRe: Reading and storing application settings in an object at startup Pin
Gerry Schmitz7-Apr-15 10:30
mveGerry Schmitz7-Apr-15 10:30 
GeneralRe: Reading and storing application settings in an object at startup Pin
Member 115846888-Apr-15 2:43
Member 115846888-Apr-15 2:43 
GeneralRe: Reading and storing application settings in an object at startup Pin
Gerry Schmitz8-Apr-15 10:49
mveGerry Schmitz8-Apr-15 10:49 
AnswerRe: Reading and storing application settings in an object at startup Pin
Nathan Minier8-Apr-15 2:37
professionalNathan Minier8-Apr-15 2:37 
QuestionPerformanceCounter RawValue is not changed\modified Pin
dushkin6-Apr-15 6:05
dushkin6-Apr-15 6:05 
I am trying to modify a PerformanceCounter I have created in C#. But it doesn't seem to be that it is being changed. This counter needs actualy to be a flag : 0 or 1.

I took the following code from the codeproject. It created the collectors category along with the counters well. But the RawValue always shows 0!

I am working on Win7/64.

Can you advise please?
C#
    using System;
using System.Diagnostics;
using System.Runtime.InteropServices;

namespace PerformanceCounterSample
{
    /// <summary>
    /// Entry class for the sample
    /// </summary>
    class PerformanceCounterSampleStarter
    {
        /// <summary>
        /// Imports the <code>QueryPerformanceFrequency</code> me  thod into the class. The method is used to measure the current
        /// tickcount of the system.
        /// </summary>
        /// <param name="ticks">current tick count</param>
        [DllImport("Kernel32.dll")]
        public static extern void QueryPerformanceCounter(ref long ticks);

<pre>
    /// <summary>
    /// Main thread
    /// </summary>
    [STAThread]
    static void Main(string[] args)
    {
        PerformanceCounterSample test = new PerformanceCounterSample();
        Random rand = new Random();
        long startTime = 0;
        long endTime = 0;

        for (int i=0; i<1000; i++)
        {
            // measure starting time
            QueryPerformanceCounter(ref startTime);

            System.Threading.Thread.Sleep(rand.Next(500));

            // measure ending time
            QueryPerformanceCounter(ref endTime);

            // do some processing
            test.DoSomeProcessing(endTime - startTime);
        }
    }
}

/// <summary>
/// The PerformanceCounterSample class sets up a performance counter category called "JamboCpmTool" if it does not already
/// exists and adds some counters to it. It provides a method to increment these counters.
/// </summary>
public class PerformanceCounterSample

{
private PerformanceCounter m_cntrJoinConctConf_VPG_MyJamboLogin;

public PerformanceCounterSample()
{
if (!PerformanceCounterCategory.Exists("JamboCpmTool"))
{
CounterCreationDataCollection counters = new CounterCreationDataCollection();

CounterCreationData VPG_MyJamboLogin = new CounterCreationData();
VPG_MyJamboLogin.CounterName = "JoinConnectConf_VPG_MyJamboLogin";
VPG_MyJamboLogin.CounterHelp = "Join Connect Conf VPG MyJambo Login Success";
VPG_MyJamboLogin.CounterType = PerformanceCounterType.NumberOfItems64;
counters.Add(VPG_MyJamboLogin);

// create new category with the counters above
System.Diagnostics.PerformanceCounterCategory.Create("JamboCpmTool", "Sample category for Codeproject", PerformanceCounterCategoryType.SingleInstance, counters);
}

// create counters to work with
m_cntrJoinConctConf_VPG_MyJamboLogin = new PerformanceCounter();
m_cntrJoinConctConf_VPG_MyJamboLogin.CategoryName = "JamboCpmTool";
m_cntrJoinConctConf_VPG_MyJamboLogin.CounterName = "JoinConctConf_VPG_MyJamboLogin";
m_cntrJoinConctConf_VPG_MyJamboLogin.MachineName = ".";
m_cntrJoinConctConf_VPG_MyJamboLogin.ReadOnly = false;
m_cntrJoinConctConf_VPG_MyJamboLogin.RawValue = 0;
}

///
/// Increments counters.
///

/// <param name="ticks" />The number of ticks the AverageTimer32 counter must be incremented by
public void DoSomeProcessing(long ticks)
{
m_cntrJoinConctConf_VPG_MyJamboLogin.RawValue = 100L;
Console.WriteLine("m_cntrJoinConctConf_VPG_MyJamboLogin = " + m_cntrJoinConctConf_VPG_MyJamboLogin.RawValue);
}
}
}

QuestionTextbox for numbers C# Pin
Member 114516056-Apr-15 5:06
Member 114516056-Apr-15 5:06 
AnswerRe: Textbox for numbers C# Pin
PIEBALDconsult6-Apr-15 5:09
mvePIEBALDconsult6-Apr-15 5:09 
GeneralRe: Textbox for numbers C# Pin
Member 1145160512-Apr-15 9:23
Member 1145160512-Apr-15 9:23 
AnswerRe: Textbox for numbers C# Pin
Ravi Bhavnani6-Apr-15 6:05
professionalRavi Bhavnani6-Apr-15 6:05 
QuestionQuery error: no such column Pin
DPaul19946-Apr-15 4:17
DPaul19946-Apr-15 4:17 
AnswerRe: Query error: no such column Pin
Dave Kreskowiak6-Apr-15 4:50
mveDave Kreskowiak6-Apr-15 4:50 
GeneralRe: Query error: no such column Pin
DPaul19946-Apr-15 5:40
DPaul19946-Apr-15 5:40 
GeneralRe: Query error: no such column Pin
Dave Kreskowiak6-Apr-15 6:26
mveDave Kreskowiak6-Apr-15 6:26 
GeneralRe: Query error: no such column Pin
DPaul19946-Apr-15 6:41
DPaul19946-Apr-15 6:41 
GeneralRe: Query error: no such column Pin
Dave Kreskowiak6-Apr-15 7:35
mveDave Kreskowiak6-Apr-15 7:35 
GeneralRe: Query error: no such column Pin
DPaul19946-Apr-15 8:07
DPaul19946-Apr-15 8:07 
GeneralRe: Query error: no such column Pin
Dave Kreskowiak6-Apr-15 8:22
mveDave Kreskowiak6-Apr-15 8:22 
GeneralRe: Query error: no such column Pin
DPaul19946-Apr-15 8:26
DPaul19946-Apr-15 8:26 
QuestionHow to pass folder hierarchy when creating zip file from memory stream using DotNetZip library Pin
Tridip Bhattacharjee6-Apr-15 1:09
professionalTridip Bhattacharjee6-Apr-15 1:09 
AnswerRe: How to pass folder hierarchy when creating zip file from memory stream using DotNetZip library Pin
Eddy Vluggen6-Apr-15 2:42
professionalEddy Vluggen6-Apr-15 2:42 
AnswerRe: How to pass folder hierarchy when creating zip file from memory stream using DotNetZip library Pin
Dr Gadgit6-Apr-15 4:03
Dr Gadgit6-Apr-15 4:03 
AnswerRe: How to pass folder hierarchy when creating zip file from memory stream using DotNetZip library Pin
Dave Kreskowiak6-Apr-15 4:43
mveDave Kreskowiak6-Apr-15 4:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.