Yili Zhao
2014-02-06 14:20:57 UTC
Hi,
I am developing an application with wxWidgets 3.0, and after receive a
menuitem command, I want to do like these:
-----------------------------------------------------------------------------------------------------------------------------------------------------
EVT_MENU(ID_CREATE_ALPHA, MyFrame::OnCreateAlpha)
void MyFrame::OnCreateAlpha(wxCommandEvent &event)
{
do a long time-consumed task;
}
------------------------------------------------------------------------------------------------------------------------------------------------------
The most important thing is that I want to run a long time-consumed task
in event handler "OnCreateAlpha".
In Java/Swing, all UI events should be processed in UI thread or the main
thread, and there is only One UI thread, so it is a single thread model.
How about the wxWidgets UI model? Is it a single thread model like Swing?
And the event handler "OnCreateAlpha" runs in which thread, in UI thread
or in a separate thread?
In order to avoid blocking the user interface, I plan to do like this:
1. execute the "long time-consumed task" in a separate worker thread;
2. In the task running process, I want to report the running progress to
the main frame, so that the main frame can display a progress bar to let
user know the current status;
3. When the task completed, it can notify the main frame, and the main
frame can response to this event (maybe repaint its client area).
How can I implement this asynchronous task model in wxWidgets?
Are there some helper class like "AsyncTask" in Android?
Sample code would be really helpful, and thanks very much!
I am developing an application with wxWidgets 3.0, and after receive a
menuitem command, I want to do like these:
-----------------------------------------------------------------------------------------------------------------------------------------------------
EVT_MENU(ID_CREATE_ALPHA, MyFrame::OnCreateAlpha)
void MyFrame::OnCreateAlpha(wxCommandEvent &event)
{
do a long time-consumed task;
}
------------------------------------------------------------------------------------------------------------------------------------------------------
The most important thing is that I want to run a long time-consumed task
in event handler "OnCreateAlpha".
In Java/Swing, all UI events should be processed in UI thread or the main
thread, and there is only One UI thread, so it is a single thread model.
How about the wxWidgets UI model? Is it a single thread model like Swing?
And the event handler "OnCreateAlpha" runs in which thread, in UI thread
or in a separate thread?
In order to avoid blocking the user interface, I plan to do like this:
1. execute the "long time-consumed task" in a separate worker thread;
2. In the task running process, I want to report the running progress to
the main frame, so that the main frame can display a progress bar to let
user know the current status;
3. When the task completed, it can notify the main frame, and the main
frame can response to this event (maybe repaint its client area).
How can I implement this asynchronous task model in wxWidgets?
Are there some helper class like "AsyncTask" in Android?
Sample code would be really helpful, and thanks very much!
--
Yili Zhao
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Yili Zhao
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users