Problem with WindowEvent() - Possible Bug?
Posted: Wed Feb 25, 2004 4:45 am
I've written a small program that only provides a progress bar which updates every 20 ms. The program checks for a file to be created by another program. Once the file is created, the progress bar goes to 100% for 300ms, and then quits.
I was using (pseudo code):
The problem was that it was taking 11 seconds to report that the file was created, no matter how small the file was. I could get it to report the file as having been created much more quickly by clicking anywhere on the window!
I changed the code to use a timer (really wanted to avoid using a timer... oh well
) and that works well: small files are reported as being created in 3 seconds (as expected). Here's the pseudo code:
For some reason, WindowEvent() is affecting the Rename() command. Instead of checking for the file using the Rename() command, I tried ExamineDirectory() and OpenFile() and got the same results.
It this a PB bug, or am I doing something wrong?
I was using (pseudo code):
Code: Select all
Repeat
; Check for events (to prevent mouse from showing as an hourglass)
event = WindowEvent()
; Check every 20 ms
delay(20)
; Update the progress bar
Show_Progress()
; attempt to rename target file to itself (fails if file not yet created)
Result = RenameFile(OutputFile$, OutputFile$)
Until Result = #True
; Show 100% Complete
Show_Progress(100)
Delay(300)
I changed the code to use a timer (really wanted to avoid using a timer... oh well

Code: Select all
;Setup a 20 ms timer
SetTimer_(WindowID(),1,20,0)
Repeat
; Check for events (to prevent mouse from showing as an hourglass)
event = WindowEvent()
If Event = #WM_TIMER
; Update the progress bar
Show_Progress()
; attempt to rename target file to itself (fails if file not yet created)
Result = RenameFile(OutputFile$, OutputFile$)
Endif
Until Result = #True
; Show 100% Complete
Show_Progress(100)
Delay(300)
It this a PB bug, or am I doing something wrong?