开发者

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

  1. Take two buttons wxButton *stop, *resume
  2. Create two button events:

    void onstopbuttonclick(wxCommandEvent & event);
    void onresumebuttonclick(wxCommandEvent & event);
    
  3. At stop button event, write:

    void login::onstopbuttonclick(wxCommandEvent& evt)
    {
        temper->Pause();//temper is object of thread class      
    }
    
  4. At resume button event, write:

    void login::onresumebuttonclick(wxCommandEvent& evt)
    {
        temper->Resume();
    }
    
  5. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜