 |
|
|
Topic: On Comm Event
|
By: Michael Hornback | Posted on: Aug 24 2015 at 05:46:59 PM | I have been using my program for several years now which worked fine under MSComm32. However it stopped working with Windows 10. I installed your SComm32 and everything works fine except for one glitch. While waiting for a 'Receive SComm1.CommEvent', I am performing a 'Do___ Loop' routine which increments and displays a counter until a sensor is tripped. Using MSComm it would pull me out of that routine when the On Comm event took place, however with SComm it ignores any Event while in this loop. Is there anything that comes to mine why MSComm worked doing this and SComm does not? | |
By: Guest | Posted on: Aug 24 2015 at 08:35:19 PM | I think scomm32 is using a delegate to fire the oncomm event on the application's own thread rather than the comm background thread. This makes it work better with modern UI's.
A downside of that is that if you have the application in a loop them the application will not get the event. Looping isn't good. You shouldn't do that but if you really must loop then you'd need to call doevents every so often to allow events to fire.
Calling doevents in a loop isn't good either. Maybe setup a counter so you're not calling doevents every loop. | |
By: Support | Posted on: Aug 24 2015 at 08:52:45 PM | It's not a true "delegate" but yes. The OnComm event does fire on the UI thread (in a forms application) and, as 'guest' said a locked loop on the application thread would prevent the OnComm event being noticed by the application. Also, as guest said, loops like that are not good. But if there's no other way then occasional doevents would be required. | |
By: Michael | Posted on: Aug 26 2015 at 05:45:15 PM | Yeah.... already had 'Do Events' in the routine. I tried removing it and adding more but didn't help. I can live without displaying the Timer running in real-time, but was just curious why it worked fine with MSComm and not SComm. I'm actually surprised that it ever worked with MSComm when you think about it.
Thanks all. | |
|