The simplest sample for QuickCounters might look as follows. Every press of the 'c' key will cause a request to SetComplete; other keys will cause SetAbort.

Use the viewer application to install the xml. As you interact with the console app, you will be able to observe one request always "executing", in addition to how many requests have started, completed, and failed. You will also see execution time (time before you hit a key) and per second, per minute, per hour metrics. If you press and hold a key, you can see the appropriate slopes and spikes in perfmon.

Xml:

<?xml version="1.0" encoding="utf-8" ?>
<InstrumentedApplication>
	<Name>UserGroupDemo</Name>
	<Description></Description>
	<Component>
		<Name>UserGroupDemoComponent</Name>
		<Description></Description>
		<RequestTypes>
			<RequestType>
				<Name>DoWork</Name>
				<Description></Description>
			</RequestType>
		</RequestTypes>
	</Component>
</InstrumentedApplication>


Code:

using System;
using System.Collections.Generic;
using System.Text;

using QuickCounters;

namespace UserGroupDemo
{
   class Program
   {
      static void Main(string[] args)
      {
         while (true)
         {
            DoWork();
         }
      }

      public static void DoWork()
      {
         RequestType request = RequestType.Attach("UserGroupDemoComponent",
            "DoWork");

         try
         {
            request.BeginRequest();
            ConsoleKeyInfo keyInfo = Console.ReadKey();
            if(keyInfo.KeyChar == 'c')
               request.SetComplete();
            else
               throw(new Exception());
         }
         catch
         {
            request.SetAbort();       
         }

      }
   }
}

Last edited Dec 14, 2006 at 1:26 PM by scolestock, version 2

Comments

No comments yet.