git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59039
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
This category is for any event used to send notifications from the
secondary threads to the main one or in general for notifications among
different threads (which may or may not be user-generated).
This category is for any event used to send notifications from the
secondary threads to the main one or in general for notifications among
different threads (which may or may not be user-generated).
+ See e.g. wxThreadEvent.
*/
wxEVT_CATEGORY_THREAD = 16,
*/
wxEVT_CATEGORY_THREAD = 16,
fields of this object are used by it, notably any wxString members of
the event object must not be shallow copies of another wxString object
as this would result in them still using the same string buffer behind
fields of this object are used by it, notably any wxString members of
the event object must not be shallow copies of another wxString object
as this would result in them still using the same string buffer behind
- the scenes. For example
+ the scenes. For example:
@code
void FunctionInAWorkerThread(const wxString& str)
{
@code
void FunctionInAWorkerThread(const wxString& str)
{
+ Note that you can use wxThreadEvent instead of wxCommandEvent
+ to avoid this problem:
+ @code
+ void FunctionInAWorkerThread(const wxString& str)
+ {
+ wxThreadEvent evt;
+ evt->SetString(str);
+
+ // wxThreadEvent::Clone() makes sure that the internal wxString
+ // member is not shared by other wxString instances:
+ wxTheApp->QueueEvent( evt.Clone() );
+ }
+ @endcode
+
Finally notice that this method automatically wakes up the event loop
if it is currently idle by calling ::wxWakeUpIdle() so there is no need
to do it manually when using it.
Finally notice that this method automatically wakes up the event loop
if it is currently idle by calling ::wxWakeUpIdle() so there is no need
to do it manually when using it.