Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is application.doevents() the right method?

Status
Not open for further replies.

bminaeff

Programmer
Dec 26, 2007
49
US
I have a subroutine in my program that takes data in from a PLC and parses it. The first piece of data I get is a barcode from a scanner. If the scanner can not read the barcode it will send me a "?". When I see this I open a new form , a dialog, called Noreadbox which waits for a user to manually enter this data. So my line of code is Noreadbox.ShowDialog(). This works fine, BUT my class also has another subroutine that prints a barcode and applies to a box in-motion. This print subroutine is called when I notice the state of a sensor connected to my PLC changes.

What's happening is that when I get a bad scan, this dialog pops up and my print subroutine is never called. How can I jump out of this parsing routine and print then return back when I finally get a user to input data?

Thanks
 
I'd say run the parsing routine in its own thread. Then if the dialog pops up, it's that thread that is "frozen" and your main program is still available to respond to events.

If you're unsure how to do threading, there is a good 3-part tutorial on threading in the FAQ section of this forum. Just click the FAQs button (under this thread's title) and scroll down to the "How To" section. The threading tutorials are near the top of that section.



I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top