Arduino UNO and Visual Studio 2012

hello!

i just want a little help with an issue here. i will be simplistic.

i have an arduino UNO R3 with the following code:

void setup() {
   Serial.begin(9600);
}
void loop() {
\\stuff
}

void serialEvent(){
Serial.flush();
Serial.println(millis());
}

and then in visual studio i have something like this: (arduino is the name of the serial port)

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        arduino.Write("request")
        TextBox1.Text = arduino.ReadLine()
        'use read value for some other stuff here
    End Sub

i want to use a timer tick on visual studio (shown as a button press on code here) to request some information from arduino (it will be a LM35 temperature value). but it seems that once it gets in the “serial event” block it goes on forever. it keeps flooding the serial data with millis() without requesting from visual studio (the TX light keeps blinking).
i want to get the millis() on the time that is requested from visual studio.
i will still add something to make visual studio wait for the complete string from arduino, but first i have to solve this.

any idea why this happens and how to avoid this? already have looked up for an answer here but found nothing.
thanks a lot!

Nothing happens in loop. All the action takes place in the serialEvent() function. In that function, the first thing you do is block until all the serial data that has been sent has been shifted out. Then, you print something. Why? The flush(), if it is to have any meaning, needs to be AFTER the print() call.

The serialEvent() method is called only when there is serial data to read. Why do you not then read that data?

but it seems that once it gets in the "serial event" block it goes on forever. it keeps flooding the serial data with millis() without requesting from visual studio (the TX light keeps blinking).

You never read anything, so serialEvent() is going to be called over and over again. Read the data that is present if you want to Arduino to not keep sending data.