Re: Sleep Command for Window Methods?



Joe Strout <joe@xxxxxxxxxx> wrote:

The term "entire main thread" suggests some misunderstanding. A thread
sleeps, or it doesn't sleep. It can't partially sleep.

Ok, but where in the docs is the "main thread" and its behavior spelled out?
How am I am supposed to know how these things work?

No, of course it's not impossible; you can have as many threads running
as you want, as I believe was already explained to you. If you stoutly
refuse to create threads for the different tasks you want to execute
simultaneously, then yes, of *course* they don't execute simultaneously.

I am creating threads. It is their interaction with my window methods that are
the problem.

if your processing takes longer than some reasonable value of
"immediately" then you should do it in a thread.

And that means that all database-update code must be done in threads (assuming
you want it to be bullet-proof) because sometimes the database will return a
"database is locked" error. Moving all database-update code to threads simply
strikes me as lacking in elegance.

Threads don't make spaghetti code; I use them whenever they're needed
and my code comes out neat. Yours can too. Just let go of this strange
desire you seem to have to want your code to behave like it's threaded,
without actually using threads. It's like saying, "I'm not willing to
put gas into my car, or switch to an electric car, but when I push the
gas pedal it doesn't go -- what's the deal?!?" Just put some friggin'
gas in it and get on with your app. :)

If I have to take two lines of code out of a window and move it into a thread,
I call that "spaghetti code". In object-oriented design, a window's code
ideally would reside within the window. If I want to execute this code:

db.SQLExecute("Some SQL Insert or Update")
db.Commit

...I cannot reliably do it in a window method. Sometimes the database will be
locked and the commit will fail. Putting the code into a loop and trying it
repeatedly until db.ErrorCode=0 will result in my app looking frozen. No
matter what device is used: sleeping the main thread, coding a tight loop,
using a semaphore, etc., the app will look frozen.

I want my windows to behave like independant objects, but I guess RB simply
does not work that way. I have been rasing this issue for a few months now,
and thought that I had a solution, but as far as I can tell the only real
solution is the hideously horrible approach of scattering my db-update code to
a swarm of threads.

Matt

Posted with NewzToolz. Free RAR, PAR, and yEnc decoders.
Get your free copy at www.techsono.com.



.



Relevant Pages

  • Re: DOS app annoyance
    ... but I have extensive database scripts written for it and it gets the job ... The app runs perfectly in a DOS window on my home PC's ...
    (microsoft.public.windowsxp.general)
  • Re: displaying a form
    ... you can have the name of your App in the title bar and your own icon if you wish. ... You can minimize the database window, ...
    (microsoft.public.access.forms)
  • Re: Sleep Command for Window Methods?
    ... "database is locked" error. ... Then the rest of your app doesn't have to worry about it; ... In object-oriented design, ... a window's code ideally would reside within the window. ...
    (comp.lang.basic.realbasic)
  • Re: Message Alert
    ... You or another user can press the F11 key to show the database window ... So the two strSQL lines needs to be changed also: ... assembled strSQL by pressing Ctrl + G, which opens the Immediate ...
    (microsoft.public.access.modulesdaovba)
  • Re: Access/Comcast/Digital Conversion
    ... I did use the Shift-Key trick and that did open the database object window. ... Tony Toews, Microsoft Access MVP ...
    (microsoft.public.access.tablesdbdesign)