hello out there

i have a program i made to scan barcodes and reformat the data it gets from com2

now when the thing scanns theres a function called
to a class but if there is no new data present it just sit's
there waiting for new data ? and will no go any further
is there a way to test a fuction if it has data or if it empty ?
and make it do something not just sit there im new to c++
and help is greatly appreciated if i worded something in correctly
i apologize

while (exit != 1)
      char zData = aPort.read (); // read com two data var by var
      char key = zData;
keybd_event(VkKeyScan(key),0x9e,0 , 0); // Press
keybd_event(VkKeyScan(key),0x9e, KEYEVENTF_KEYUP,0); // Release
8 Years
Discussion Span
Last Post by HITMANOF44th

Check the class of whatever aPort is to see if it has a non-blocking read, or some way to query the port for incoming data. If not, you might want to look into spawning a separate process or thread for inputting data. At least that way the whole program won't lock up while waiting for input.


>would you happen to know any good example on how to thread?
Proper multi-threading is non-trivial, so you're not likely to find one example that will teach you what you need. My recommendation would be to browse over to codeproject.com and read up on the threading articles.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.