minor cleaning: use %p instead of 0x%lx; clear in the menu name which is the thread which is stopped/paused/resumed
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59056 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
122cf17b13
commit
ff8151c16e
@ -107,6 +107,8 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// event handlers
|
// event handlers
|
||||||
|
// --------------
|
||||||
|
|
||||||
void OnQuit(wxCommandEvent& event);
|
void OnQuit(wxCommandEvent& event);
|
||||||
void OnClear(wxCommandEvent& event);
|
void OnClear(wxCommandEvent& event);
|
||||||
|
|
||||||
@ -117,8 +119,6 @@ private:
|
|||||||
void OnResumeThread(wxCommandEvent& event);
|
void OnResumeThread(wxCommandEvent& event);
|
||||||
|
|
||||||
void OnStartWorker(wxCommandEvent& event);
|
void OnStartWorker(wxCommandEvent& event);
|
||||||
void OnWorkerEvent(wxThreadEvent& event);
|
|
||||||
void OnUpdateWorker(wxUpdateUIEvent& event);
|
|
||||||
|
|
||||||
void OnExecMain(wxCommandEvent& event);
|
void OnExecMain(wxCommandEvent& event);
|
||||||
void OnExecThread(wxCommandEvent& event);
|
void OnExecThread(wxCommandEvent& event);
|
||||||
@ -127,6 +127,12 @@ private:
|
|||||||
void OnAbout(wxCommandEvent& event);
|
void OnAbout(wxCommandEvent& event);
|
||||||
|
|
||||||
void OnIdle(wxIdleEvent &event);
|
void OnIdle(wxIdleEvent &event);
|
||||||
|
void OnWorkerEvent(wxThreadEvent& event);
|
||||||
|
void OnUpdateWorker(wxUpdateUIEvent& event);
|
||||||
|
|
||||||
|
|
||||||
|
// thread helper functions
|
||||||
|
// -----------------------
|
||||||
|
|
||||||
// helper function - creates a new thread (but doesn't run it)
|
// helper function - creates a new thread (but doesn't run it)
|
||||||
MyThread *CreateThread();
|
MyThread *CreateThread();
|
||||||
@ -138,6 +144,9 @@ private:
|
|||||||
void DoLogThreadMessages();
|
void DoLogThreadMessages();
|
||||||
|
|
||||||
|
|
||||||
|
// internal variables
|
||||||
|
// ------------------
|
||||||
|
|
||||||
// just some place to put our messages in
|
// just some place to put our messages in
|
||||||
wxTextCtrl *m_txtctrl;
|
wxTextCtrl *m_txtctrl;
|
||||||
|
|
||||||
@ -279,7 +288,7 @@ bool MyApp::OnInit()
|
|||||||
|
|
||||||
// uncomment this to get some debugging messages from the trace code
|
// uncomment this to get some debugging messages from the trace code
|
||||||
// on the console (or just set WXTRACE env variable to include "thread")
|
// on the console (or just set WXTRACE env variable to include "thread")
|
||||||
//wxLog::AddTraceMask("thread");
|
wxLog::AddTraceMask("thread");
|
||||||
|
|
||||||
// Create the main frame window
|
// Create the main frame window
|
||||||
MyFrame *frame = new MyFrame((wxFrame *)NULL, _T("wxWidgets threads sample"),
|
MyFrame *frame = new MyFrame((wxFrame *)NULL, _T("wxWidgets threads sample"),
|
||||||
@ -311,11 +320,10 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
|||||||
EVT_MENU(THREAD_SHOWCPUS, MyFrame::OnShowCPUs)
|
EVT_MENU(THREAD_SHOWCPUS, MyFrame::OnShowCPUs)
|
||||||
EVT_MENU(THREAD_ABOUT, MyFrame::OnAbout)
|
EVT_MENU(THREAD_ABOUT, MyFrame::OnAbout)
|
||||||
|
|
||||||
EVT_UPDATE_UI(THREAD_START_WORKER, MyFrame::OnUpdateWorker)
|
|
||||||
EVT_MENU(THREAD_START_WORKER, MyFrame::OnStartWorker)
|
EVT_MENU(THREAD_START_WORKER, MyFrame::OnStartWorker)
|
||||||
|
|
||||||
|
EVT_UPDATE_UI(THREAD_START_WORKER, MyFrame::OnUpdateWorker)
|
||||||
EVT_THREAD(WORKER_EVENT, MyFrame::OnWorkerEvent)
|
EVT_THREAD(WORKER_EVENT, MyFrame::OnWorkerEvent)
|
||||||
|
|
||||||
EVT_IDLE(MyFrame::OnIdle)
|
EVT_IDLE(MyFrame::OnIdle)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
@ -338,12 +346,12 @@ MyFrame::MyFrame(wxFrame *frame, const wxString& title,
|
|||||||
wxMenu *menuThread = new wxMenu;
|
wxMenu *menuThread = new wxMenu;
|
||||||
menuThread->Append(THREAD_START_THREAD, _T("&Start a new thread\tCtrl-N"));
|
menuThread->Append(THREAD_START_THREAD, _T("&Start a new thread\tCtrl-N"));
|
||||||
menuThread->Append(THREAD_START_THREADS, _T("Start &many threads at once"));
|
menuThread->Append(THREAD_START_THREADS, _T("Start &many threads at once"));
|
||||||
menuThread->Append(THREAD_STOP_THREAD, _T("S&top a running thread\tCtrl-S"));
|
menuThread->Append(THREAD_STOP_THREAD, _T("S&top the last spawned thread\tCtrl-S"));
|
||||||
menuThread->AppendSeparator();
|
menuThread->AppendSeparator();
|
||||||
menuThread->Append(THREAD_PAUSE_THREAD, _T("&Pause a running thread\tCtrl-P"));
|
menuThread->Append(THREAD_PAUSE_THREAD, _T("&Pause the last spawned running thread\tCtrl-P"));
|
||||||
menuThread->Append(THREAD_RESUME_THREAD, _T("&Resume suspended thread\tCtrl-R"));
|
menuThread->Append(THREAD_RESUME_THREAD, _T("&Resume the first suspended thread\tCtrl-R"));
|
||||||
menuThread->AppendSeparator();
|
menuThread->AppendSeparator();
|
||||||
menuThread->Append(THREAD_START_WORKER, _T("Start &worker thread\tCtrl-W"));
|
menuThread->Append(THREAD_START_WORKER, _T("Start a &worker thread\tCtrl-W"));
|
||||||
menuBar->Append(menuThread, _T("&Thread"));
|
menuBar->Append(menuThread, _T("&Thread"));
|
||||||
|
|
||||||
wxMenu *menuExec = new wxMenu;
|
wxMenu *menuExec = new wxMenu;
|
||||||
@ -751,7 +759,7 @@ void *MyThread::Entry()
|
|||||||
{
|
{
|
||||||
wxString text;
|
wxString text;
|
||||||
|
|
||||||
text.Printf(wxT("Thread 0x%lx started (priority = %u).\n"),
|
text.Printf(wxT("Thread %p started (priority = %u).\n"),
|
||||||
GetId(), GetPriority());
|
GetId(), GetPriority());
|
||||||
WriteText(text);
|
WriteText(text);
|
||||||
// wxLogMessage(text); -- test wxLog thread safeness
|
// wxLogMessage(text); -- test wxLog thread safeness
|
||||||
@ -770,14 +778,14 @@ void *MyThread::Entry()
|
|||||||
if ( TestDestroy() )
|
if ( TestDestroy() )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
text.Printf(wxT("[%u] Thread 0x%lx here.\n"), m_count, GetId());
|
text.Printf(wxT("[%u] Thread %p here.\n"), m_count, GetId());
|
||||||
WriteText(text);
|
WriteText(text);
|
||||||
|
|
||||||
// wxSleep() can't be called from non-GUI thread!
|
// wxSleep() can't be called from non-GUI thread!
|
||||||
wxThread::Sleep(1000);
|
wxThread::Sleep(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
text.Printf(wxT("Thread 0x%lx finished.\n"), GetId());
|
text.Printf(wxT("Thread %p finished.\n"), GetId());
|
||||||
WriteText(text);
|
WriteText(text);
|
||||||
// wxLogMessage(text); -- test wxLog thread safeness
|
// wxLogMessage(text); -- test wxLog thread safeness
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user