Hello,
Hope someone can help me out.
I have a program running on purebasic 4.6 that is supposed to run continuously without attending to it.. and checks
for presence of certain files in the server to do a job .
as usual i used "Repeat " syntax.
and Event = WaitWindowEvent() etc
so that an if exist file checks for the presence of the file.
The funny part is , the program stops when the mouse is not actively over the page's window.
That means of I move the mouse outside the boundary of the windows frame, or if I minimise it,
when means the mouse if not over it , it does not run.
The moment I move the mouse over it , it runs again.
How do I overcome this?
Thanks for your assistance
alan
Program not running if mouse not over the windows page
Re: Program not running if mouse not over the windows page
Okay .. I solved it. Just put say 10 to WaitWindowEvent(10)
Found my mistake
works fine now
Found my mistake
works fine now
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: Program not running if mouse not over the windows page
The inclusion of a parameter in the WaitWindowEvent() loop, while it will indeed solve the problem of the program not doing its job without an event (in this case a mousemove), is not the ideal solution. This is because your program will be doing its "heavy lifting" right in the GUI main loop, which will cause the GUI to respond sluggishly or seemingly not at all if a user tries to move around in it or minimize/restore it while it's busy. A much better and more professional approach is to start a worker thread just before you open the window and this thread can do the waiting and working while the GUI is free to do its own thing and respond instantly. This way, if a CloseWindow() is received while the thread is actually doing something (which can be known by the thread setting a global variable true and false as needed) you can display a message advising the user of such and asking if they really want to interrupt the work and close. If it turns out that they do, the thread can then wrap up its task gracefully before the main loop closes the window. To accomplish this the main loop would set a global variable true, which the thread would watch for, and then employ WaitThread() to enable continuing the termination after the thread has finished.
BERESHEIT