C#C
C#2y ago
De1337

freeze winform app until loop exits

I have an app running and when a specific button is hit it runs a bunch of tasks. I want to freeze the tasks at one point until a loop is finished. Not sure why this code isn't doing that:

loop = true;

    //loop while receiving data to prevent going past this point until the end
    while (loop == true)
    {
        //upon data receipt from tracer, send data to dataReceivedHandler function
        port.DataReceived += new SerialDataReceivedEventHandler(dataRecievedHandler);
    }


Later in the code I have a loop=false in my dataReceivedHandlerFuntion to break the loop but code after this code is executing prematurely
Was this page helpful?