How to ignore serial data?

Hi,
I have a C# application where when the Middle Mouse button is pressed it sends serial data '@' to the Arduino and serial data '#' when the Middle Button is released.

I am trying to produce an Arduino script where the Middle Button spams while it is held.
The problem that I am running into is once the serial data is sent once it interfers with each other and goes in and endless loop.

The idea that I had that would't involve any more trouble other than the Arduino code was to "ignore" the '#' being sent to the Arduino 10ms after the release of the Middle Mouse Button is the code to try and stop the program and Arduino script from creating and endless loop.

My code right now is in a while '@' loop but I can't figure out a way that I can "ignore" the serial data.

Thanks for the help.

My code

I don't see any code. Be sure to use code tags around it,

  so it looks
         like this.
boolean spamming = false;
void loop() {
  if(mouse.available()) {
    switch(mouse.read()) {
      case '@': spamming = true; break;
      case '#': spamming = false; break;
    }
  }

  if(spamming) spam();
}

PaulMurrayCbr:

boolean spamming = false;

void loop() {
  if(mouse.available()) {
    switch(mouse.read()) {
      case '@': spamming = true; break;
      case '#': spamming = false; break;
    }
  }

if(spamming) spam();
}

If I had a While ('@') loop for example with {

Middle Up
delay
Middle Down
}

Where would I put this code in realtion? I am bad at programming.

The Forum Moderators waste a lot of their time and there is a lot of inconvenience for Forum newcomers in the interest of combatting spam.

I don't think we should be assisting anyone who is working on a spamming program.

...R

I am bad at programming.

That's not the only thing you are bad at. You aren't good at following instructions, either.

At the top of each section of the forum, there are sticky posts that describe what you should do BEFORE posting in that part of the forum.

The one for the Programming section says "POST YOUR CODE". We have no idea what you f**ked up in code we can't see.