RE: What is the minimum number of lines to update a gui window without user clicking a button



Quoth L. D. James:
And, No.  There aren't any significantly open issues.  The code
presented by Alan works perfectly.  It has already been in production
with my clients for over a week without a glitch.

Several people (including myself) have tried to tell you that the code you
have posted here thus far is not at all thread-safe and is very likely to
explode in your face at some point.  That it appears to be working during
your testing is merely coincidental.  (One of the joys of programming with
threads, in any language or framework, is that you have to pay very close
attention to the data interactions -- it's very easy to write something that
appears to work most of the time but will do something very strange in
corner conditions.)

I'm not sure why you seem to be ignoring this.

I would be glad to implement a "gprint()" function to ease the flow for
some of my other programs/C++ scripts/applications that haven't been
implemented with the gui window, as well as some of my future project
and overall understanding and learning.  But as I mentioned, I'm
reserving that development for a future thread.

If you look at the most recent example that Andrew Potter posted, that is
pretty much exactly your desired gprint() method done in an actually
thread-safe manner.


Regarding your other question, about closing the window freezing up the
program: this is because the window cannot be closed while the background
thread is running, and you should not allow it to do so.  If you want to be
able to cancel the background operation, then you have to add in code
specifically to request that the background operation be cancelled (in a
thread safe manner) when the user attempts to close the window, and then
wait for it to actually complete running before closing down.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]