Variable update by interrupt service rotine

I am working on a program that has an integer counter this counter is deffined in Main as int Count;

i have a interrupt service routine that is used to update the variable Count
when i use Count in the ISR it is not recognised

Error 1 An object reference is required for the non-static field, method, or property ‘FEZ_Panda_II_Application1.Program.count’ e:\QUADRATURE example\QUADRATURE example\Program.cs 45 11 QUADRATURE example

how do in increment the variable count in the ISR

hope someone can help

Jos van Hertrooij
The Netherlands

Declare Count as static outside main


        private static int Count = 0;
        private static InterruptPort myPort = new InterruptPort((Cpu.Pin)FEZ_Pin.Interrupt.Di7, true, Port.ResistorMode.PullDown, Port.InterruptMode.InterruptEdgeBoth);
 
        public static void Main()
        {

            myPort.OnInterrupt += new NativeEventHandler(myPort_OnInterrupt);

            Thread.Sleep(Timeout.Infinite);

        }

        static void myPort_OnInterrupt(uint data1, uint data2, DateTime time)
        {
            Count++;
        }

thank you Count was not static now it works.

Jos

@ jos - Don’t forget to mark Eric’s post as the answer.