[wxWidgets] how to unfroze the GUI while the event is running?
Hello, I have to make a very simple GUI for my C++ mathematical model.
Basically I just need a wxTextContr window that display the output of my model as it is produced. The problem is that is is display at the end of the event call (when the model end, sometimes after hours), while I need it in real-time. I am completelly new to GUI programming, so I think what I wrote is completelly ridicolous... I would seriously appreciate on GUI programming strategies to improve my small GUI ;-). This is what I wrote: Code:
class |
If I understand you correctly then you are computing data which takes a long time; yet you want to display results as they happen rather than at the end of the computation.
Use two threads one for the gui and one for the computation, have data passing from the maths thread into a threadsafe queue and display the results in that thread. This allows the gui to be responsive whilst still computing the data, tho I would give a higher priority to the the non gui thread. |
Quote:
Can you raccomand me a tutorial on this point? (I was thinking that the thread division was just made automatically by wxWidgets when calling events) |
My knowledge of wxWidgets is very minimal(almost nothing lol), so you may be correct. If its a thread tutorial you are looking for then I would recommend Posix thread tut
|
Quote:
|
wxWidgets has a thread class you can use, wxThread.
iirc there is an entire chapter dedicated to threads in a book that is available for free from the prentice hall website. i cant think of the name of the book though.. |
Quote:
http://vig.prenhall.com/catalog/acad...473816,00.html |
I am really, really lost on all of this.
here I read: Quote:
|
What that example does not taken into account is "when the model end, sometimes after hours", it just says long computation and you want it realtime.
Quote:
Quote:
Quote:
I personally see this as the correct method to acheive what you want and is the way many guis work. Their comment I would see as a word of warning that everything may not go as you wish, if you don't have an understanding of threads and the benefits they do or do not give. On the other hand if you do not want to use threads, then you would have to stop the computation at some point to display results and then continue... If it was to be run on a dual core cpu, I would try splitting the computation into threads:) [edit]misread the comment about wxWindow::Update(). This is an option. |
Quote:
|
thanks all.. I have found the book (in PDF) and I am going to learn threads..
|
All times are GMT -5. The time now is 09:15 PM. |