This will be somewhat of a simple question, I am trying to write my first useful win32 program which involves opening a serial port using "createfile" and writing/reading with write/readfile.
I want to send a command to the port( with a sensor attached), wait for a response from the sensor(returns <CR> terminated string), display it onscreen (I am using a static label to display it) and repeat the process.
I am ok with the actual port setup, reading and writing but I am have problems with "repeating this process"
I set up a for loop which works as long as I do not click anywhere on the screen. If I do the program will hang, It is as if it is blocking the rest of the UI and does not like it if I interrupt it.
I then tried a "while loop" that checks that a "Cancel" button hasn't been pressed as if it hasn't the "port write/read" process continues but this didn't work either!
Should I be using threads for this? If so I need to learn about them as I only know their concept and not the syntax! I guess I do but want to check before I delve into the world of threads in the early days of my programming life.....