GUI's, threading and stopping the user clicking etc.

K

Kevin

I am would like to start making my programs more responsive by
introducing threading.
My programs perform reasonable size db queries and builds large
treeviews etc. I know how to create thread and set them off etc, which
leaves the GUI nice and responsive for the user.

However, this also means that they might do something that affects the
thread, like clearing the treeview, or trying to start another query
while that is running. I would say that to start off I would like to
stop the user doing ANYTHING while, say, a db query was running.

What is the best way to achieve this? One way would be to have a
global variable called boolBUSY, then every time the user tries to do
something it first checks this variable before continuing. The only
think about this way is that you have to put in in every event handler
which seems a bit clunky. Or, similarly, you could check that the
cursor is not an hourglass but this gives the same problem.

Is there a way to ignore certain user input (keyboard, mouse click
etc)?

The Eclipse Java IDE brings up a little dialog box that says something
along the lines of 'System busy, cannot interupt', which seems
reasonable.

Any pointers would be greatfully received.
Thanks
Kevin
 
M

Michael Nemtsev

Hello Kevin,

There are several cases. Disable controls that are responsible for interaction
with thread; create new dialog window where show
the process of performing thread and etc.

K> I am would like to start making my programs more responsive by
K> introducing threading.
K> My programs perform reasonable size db queries and builds large
K> treeviews etc. I know how to create thread and set them off etc,
K> which
K> leaves the GUI nice and responsive for the user.
K> However, this also means that they might do something that affects
K> the thread, like clearing the treeview, or trying to start another
K> query while that is running. I would say that to start off I would
K> like to stop the user doing ANYTHING while, say, a db query was
K> running.
K>
K> What is the best way to achieve this? One way would be to have a
K> global variable called boolBUSY, then every time the user tries to do
K> something it first checks this variable before continuing. The only
K> think about this way is that you have to put in in every event
K> handler which seems a bit clunky. Or, similarly, you could check
K> that the cursor is not an hourglass but this gives the same problem.
K>
K> Is there a way to ignore certain user input (keyboard, mouse click
K> etc)?
K>
K> The Eclipse Java IDE brings up a little dialog box that says
K> something along the lines of 'System busy, cannot interupt', which
K> seems reasonable.
K>
K> Any pointers would be greatfully received.
K> Thanks
K> Kevin
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
 
M

Mattias Sjögren

What is the best way to achieve this?

You could show a modal dialog box, possibly containing a progress bar
or something to notify the user about what's going on. Or just disable
all the relevant controls on the main form.


Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top