Maybe it is just me and I'm using too many loops/nested loops, but some of my programs use too much of the CPU. Is there a better way to wait for something to happen than a loop?
For example I've got several programs that work with a telnet display (To be more specific TN5250 through a RUMBA plug-in). Each "screen" has an ID and I have to wait for the next ID so I loop (Do Until) until the screen sends back the ID I'm waiting for. Sometimes I might have an area that has another ID I have to watch for so I might have a second loop inside waiting for it, but the most is those two loops and only occasionally. When it hits any of the loops it will cause the program to use as much of the CPU that is available until the condition is met. The rest of the time it is only moderate usage. It can sometimes take several minutes before it reaches the next screen.
Any suggestions? I haven't given it much thought, but should I think about trying to figure a way to maybe use a timer instead or something with threading I haven't figure out? What is a better way to handle this?
-I hate Microsoft!
-Forever and always forward.
For example I've got several programs that work with a telnet display (To be more specific TN5250 through a RUMBA plug-in). Each "screen" has an ID and I have to wait for the next ID so I loop (Do Until) until the screen sends back the ID I'm waiting for. Sometimes I might have an area that has another ID I have to watch for so I might have a second loop inside waiting for it, but the most is those two loops and only occasionally. When it hits any of the loops it will cause the program to use as much of the CPU that is available until the condition is met. The rest of the time it is only moderate usage. It can sometimes take several minutes before it reaches the next screen.
Any suggestions? I haven't given it much thought, but should I think about trying to figure a way to maybe use a timer instead or something with threading I haven't figure out? What is a better way to handle this?
-I hate Microsoft!
-Forever and always forward.