|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
doevents
I've written a program that requests data form a device over a serial cable using MScomm control. I send the request and set a variable 'requestpending' and then in a loop calling doevents until that variable gets reset when the data is received in the oncomm function. My request function requests 10 items one after another. This occurs every second in a timer so that those 10 data items are refreshed every second. This all works perfectly. The problem I'm having is that I have some menu's at the top (file, edit, view. . . ) and once in a while when I click on those or on items in those there is no response and I have to click again. this wasn't happening before I added this set of 10 requests with the doevents loop. I need to wait like this for previous data item before requesting the next. is there anything I should do to avoid this problem?
|
|
#2
|
||||
|
||||
|
Not having seen your code, I cannot say this for sure, but my guess is that your timer is causing the problem. Normally rather then poll for data every second I would simply stack the data as it arrives, or implement some sort of syncranisation method. I'll give you two examples to clarify what I mean.
Example 1: sub on_comm(data) 'You can do your parsing here array[index] = data index = index + 1 if (index = 10) then do_suff_with_array() index = 0 requestpending = false end if end sub sub mainloop() while requestpending doevents wend end sub This allows you to receive each piece of data independently, but not handle the data until it is all received, thus no need for the timer. It would be recommended that you have a status bar of some sort letting the user know that data is still being retrieved. Example 2: If your program is the server program waiting for a client to input 10 items, then make sure that the client program does not send the data until all 10 items have been entered, then send all the data as one string using a seperator char such as vblf of eof (if applicable) to seperate the data. I would however strongly recommend that you utilize some other method of checking for data rather then using a timer. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > ASP Development > doevents |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|