how to pause and resume wxThread with button event
I am trying to fill wxListCtrl with the database, and for this I'm using wxThread
concept. I 开发者_开发百科want to add two buttons in the frame, for pause and resume thread. How can this possible?
Finally, I got the solution - I was trying to pause and resume thread with the button event. For this
- Take two buttons
wxButton *stop, *resume
Create two button events:
void onstopbuttonclick(wxCommandEvent & event); void onresumebuttonclick(wxCommandEvent & event);
At stop button event, write:
void login::onstopbuttonclick(wxCommandEvent& evt) { temper->Pause();//temper is object of thread class }
At resume button event, write:
void login::onresumebuttonclick(wxCommandEvent& evt) { temper->Resume(); }
Write finally in Entry() method:
if(TestDestroy()) { return NULL; }
Write this before your thread code, when you click stop button this condition will be true that time and thread will not perform any work that time.
精彩评论