Counting encoders

I'm new in this, but i'm trying to make an dual encoder pulse counter, but as i'm not great in programing I'm stuck!!
So far the only thing I it can do is count one encoder and the encoder can't send a signals faster then 1.7kHz.
I'm testing with an arbitrary signal generator sending 10000 pulses, simulating the encoder.

Is there any way to the arduino read faster signals (up to 10kHz), and do it in two inputs?
I'm using Uno V3!

int state=LOW;
int lastState=LOW;
unsigned long int count=0;

void setup(){

  Serial.begin(115200);

  pinMode(12, INPUT);

  state=digitalRead(12);

}

void loop(){

  if (state==HIGH && lastState==LOW){

count++;

Serial.println(count);

}

lastState=state;

state=digitalRead(12);

}

Serial.print() is a very slow function. I think you will see a significant improvement if you only output the count at longer intervals. But you might miss a count when you do call Serial,print().

The ideal way is to use an interrupt to detect the pulses. See Nick Gammon's interrupt tutorial to get you started.

...R