Board index » cppbuilder » Program frozen when user hold the form....

Program frozen when user hold the form....


2004-03-07 04:04:29 PM
cppbuilder99
Hi all,
I noticed that if the user using the mouse to hold or to move the
Form from one location to another then the application is not
running at this time until the user will release the mouse press,
this is a problem becouse i'm drowing a graph of some measure and
when the user is holding the form then the graph is not updating
and i lose points of importent data in this graph.
So the question is how can i make the program running even if
the using is holding the Form with the left mouse key?
Thanks,
Ramy
 
 

Re:Program frozen when user hold the form....

You can acquire your data in a different thread (it is still running while
user is pushing a mouse button), store the data in a thread safe place.
Periodly the main thread (the thred you are using in the VCL) will read the
data and will show the graph. So they is no data lost.
"Ramy" < XXXX@XXXXX.COM >a écrit dans le message de
Quote

Hi all,

I noticed that if the user using the mouse to hold or to move the
Form from one location to another then the application is not
running at this time until the user will release the mouse press,
this is a problem becouse i'm drowing a graph of some measure and
when the user is holding the form then the graph is not updating
and i lose points of importent data in this graph.

So the question is how can i make the program running even if
the using is holding the Form with the left mouse key?

Thanks,
Ramy

 

Re:Program frozen when user hold the form....

Hi,
I did not understand, what is a "different thread"? how do i
create it? why does the current thread NOT running while the
user is pushing a mouse button down, but the new thread WILL
run at this time? why should there be a different between this
two threads? why can't i set my current thread also to run when
the mouse key in down?
Thanks,
Ramy
"Florent Ouchet" < XXXX@XXXXX.COM >wrote:
Quote
You can acquire your data in a different thread (it is still running while
user is pushing a mouse button), store the data in a thread safe place.
Periodly the main thread (the thred you are using in the VCL) will read the
data and will show the graph. So they is no data lost.

--
Florent.
 

{smallsort}

Re:Program frozen when user hold the form....

A lot of question.
Quote
I did not understand, what is a "different thread"?
Just look at : www.hyperdictionary.com/dictionary/multithreading
A thread is an other executing context in the same process (Application).
The executions of threads are independant one from another, but you can
synchronize them in order to use the same resources.
Quote
how do i create it?
You have to inherit the TThread class (in Classes.hpp). Simply place your
code in the Execute function.
for a complete guide of about using TThread look at the help of CBuilder.
Quote
why does the current thread NOT running while the user is
pushing a mouse button down, but the new thread WILL
run at this time?
Because the executions of different threads are independant. If one is
stalled (for example the main thread of your application when you move the
window), the other is able to run.
Quote
why should there be a different between this two threads?
One thread (yours) does the acquisition and store data in a structure in
memory (you should use Critical Sections to avoid conflicts while
writing/reading).
The other thread (the main thread - VCL) read regularly the data in memory
and display them in your graph.
Quote
why can't i set my current thread also to run when
the mouse key in down?
Because the main thread execution is paused during this time.