Search found 69 matches

by wxJack
Mon Nov 19, 2018 8:42 am
Forum: C++ Development
Topic: secondary thread accessing gui functions
Replies: 2
Views: 85

secondary thread accessing gui functions

Hi ! I know that " it is strongly recommended that no secondary threads call GUI functions " . I think it is mandatory for the writing operation, but what about the reading ones? Can I let a secondary thread t2 access to a wxListCtrl (whose pointer is passed inside the ctr) so t2 can read some value...
by wxJack
Thu Nov 01, 2018 9:47 pm
Forum: C++ Development
Topic: wxThread Kill()
Replies: 48
Views: 1247

Re: wxThread Kill()

Your answer is very useful. It has helped me clarify the situation. My understanding of the topic is getting better and better, thank you!
by wxJack
Thu Nov 01, 2018 9:39 pm
Forum: C++ Development
Topic: How to stop all the 2ndary threads from the main one?
Replies: 2
Views: 132

Re: How to stop all the 2ndary threads from the main one?

Thanks for posting @Manolo ! If you use a pointer make sure it's a member of a class and that it gets deleted only inside the class, and always at that class' dtor. In my case, it is a member of MyDialog ; I create(), Run(), and Wait() my thread inside the MyDialog class . So, is my behavior "safe"?...
by wxJack
Thu Nov 01, 2018 12:34 pm
Forum: C++ Development
Topic: How to stop all the 2ndary threads from the main one?
Replies: 2
Views: 132

How to stop all the 2ndary threads from the main one?

Hi everyone:) I want to make a wxButton " Stop all 2ndary threads " . My idea is something like the following (and it works, already tested). I only post the essential. void MyDialog::StopAllThreads(wxCommandEvent& event) { if (t1->IsRunning()) // MyThread1 class; t1 is a member of MyDialog t1->Paus...
by wxJack
Thu Nov 01, 2018 12:00 pm
Forum: C++ Development
Topic: wxThread Kill()
Replies: 48
Views: 1247

Re: wxThread Kill()

b) joinable . You must call Wait() so as to delete the thread. Sorry to the author of the thread if I use its discussion to ask a question: @Manolo thanks for posting and please correct me if I'm wrong: what you wrote is true only if the Joinable thread is created in the stack. If the thread is cre...
by wxJack
Wed Oct 24, 2018 11:01 am
Forum: C++ Development
Topic: Why is my thread detached?
Replies: 11
Views: 629

Re: Why is my thread detached?

Update: the only solution I found is the following: after t1 is finished (and the string event sent to the handler function), I can make the thread2 start inside the handler function (the only capable of passing the string argument to thread2). Did you mean this @ONEEYEMAN? Update 2: I put the strin...
by wxJack
Tue Oct 23, 2018 9:36 pm
Forum: C++ Development
Topic: Why is my thread detached?
Replies: 11
Views: 629

Re: Why is my thread detached?

Just make sure you send the event when the thread1 is about to finish and thread2 will get the appropriate value. Thank you. Great, I will put the lines about the event immediatly before "return NULL" . The only doubt I have (I didn't figure it out studying the thread sample) is : the handler funct...
by wxJack
Tue Oct 23, 2018 8:09 pm
Forum: C++ Development
Topic: Why is my thread detached?
Replies: 11
Views: 629

Re: Why is my thread detached?

Hi, Yes, you did. ;-) What I meant is - create an event that is a descendant of wxThreadEvent. Set your string as a parameter and send it when the thread exit. Create a handler of this event in the window (either main window or any other). In the handler get the parameter and do what you want with ...
by wxJack
Tue Oct 23, 2018 5:08 pm
Forum: C++ Development
Topic: Why is my thread detached?
Replies: 11
Views: 629

Re: Why is my thread detached?

Hi ! :) Sorry, I could have misunderstood what you told me.. I create it in a function binded to a wxButton. void MainDialog::OnClickButton_MyFunction(wxCommandEvent& event) { //do something and start threads } for this reason I can't do event.getString(); //did you mean something like this? because...
by wxJack
Tue Oct 23, 2018 4:20 pm
Forum: C++ Development
Topic: Why is my thread detached?
Replies: 11
Views: 629

Re: Why is my thread detached?

Hi. The thread was the same. I solved in the following way class MyThread : public wxThread { protected: MainDialog * m_parent; public: MyThread(); MyThread(MainDialog* parent, wxThreadKind kind) : wxThread(kind) { m_parent = parent; } }; class MyThread1 : public MyThread { public: MyThread1(); MyTh...
by wxJack
Mon Oct 22, 2018 8:14 pm
Forum: C++ Development
Topic: Why is my thread detached?
Replies: 11
Views: 629

Re: Why is my thread detached?

ONEEYEMAN wrote:Hi,
What wx version?
Good evening:)
3.0.4
ONEEYEMAN wrote: What OS?
windows 10.
ONEEYEMAN wrote: Is thread sample works for you
Yes, it works but I commented the line .

Code: Select all

"// #include "../sample.xpm" " 
Maybe I made a mistake in the code I wrote..I'm still trying to figure it out.
Thank you very much
by wxJack
Mon Oct 22, 2018 4:19 pm
Forum: C++ Development
Topic: Why is my thread detached?
Replies: 11
Views: 629

Why is my thread detached?

Hi everyone. I have a class MyThread1 that derives from MyThread in my .h file ; In my .cpp file I want MyThread1* t1 = new MyThread1(this, wxTHREAD_JOINABLE) to be joinable, and I verify it with IsDetached() fucntion. But it returns true, so the thread I want to be Joinable is detached, how can I f...
by wxJack
Sun Oct 14, 2018 6:31 pm
Forum: C++ Development
Topic: wxThread & GUI
Replies: 26
Views: 790

Re: wxThread & GUI

Wow, I'll try your suggestion as soon as I can ! Thanks !
Can I set more than one string (or more than one int) at once and send them without any trouble in this way ?
by wxJack
Sun Oct 14, 2018 2:29 pm
Forum: C++ Development
Topic: wxThread & GUI
Replies: 26
Views: 790

Re: wxThread & GUI

This sample worked for me. Core code parts: virtual void *Entry() { Sleep(1000); for(int i=0; i<100; i++) { wxLogDebug("adding item %d", i ); wxCommandEvent event(wxEVT_BUTTON, LISTCTRL_UPDATE_INT); event.SetInt(i); event.SetString( wxString::Format("item %d, column 1", i ) ); m_listener->AddPendin...
by wxJack
Sat Oct 13, 2018 7:13 pm
Forum: C++ Development
Topic: wxThread & GUI
Replies: 26
Views: 790

Re: wxThread & GUI

Thanks DM, it's not a problem, take your time:) Meanwhile, I tell you more: from the few experiments I've done, I can say that the order matters: the functions that update the GUI take as parameters first the int and then the string, so the thread must send them in this order. If I invert the order ...