But wxCondition needs a mutex, that is not necesary for semaphor, but posibly I just understood everything wrong.doublemax wrote:You can probably achieve the same with wxSemaphore, but as wxCondition already has sample code that does exactly what you want, i'd go with that.
Search found 201 matches
- Wed Nov 28, 2018 2:56 pm
- Forum: C++ Development
- Topic: wxThread Kill()
- Replies: 48
- Views: 7007
Re: wxThread Kill()
- Tue Nov 27, 2018 2:49 pm
- Forum: C++ Development
- Topic: wxThread Kill()
- Replies: 48
- Views: 7007
Re: wxThread Kill()
If you want to get fancy, you can use wxCondition to wait for the thread to end. This will still block the execution of the main thread, but it won't be a busy loop that uses CPU. https://docs.wxwidgets.org/trunk/classwx_condition.html Thanks, will take a look at that wxCondition. What about wxSema...
- Fri Nov 23, 2018 12:22 pm
- Forum: C++ Development
- Topic: wxThread Kill()
- Replies: 48
- Views: 7007
Re: wxThread Kill()
But that´s still buisy waiting. I mean it´s defenetly better then endles loop, but I am wondering why there is no good mechanism in C++ to manage something like that. I mean in Java something like that could be done very easy. Well, as DoubleMax already said: At some point the code is waiting, in t...
- Thu Nov 22, 2018 3:21 pm
- Forum: C++ Development
- Topic: wxThread Kill()
- Replies: 48
- Views: 7007
Re: wxThread Kill()
Using an endless loop to wait for the end of thread and after that leaving it with breack is a really ugly solution in my opinion. I mean while(m_pThread); would be a bit better, but still a waste of resorces. I thought Delete waits for thread to call TestDestroy() and only after that the main appl...
- Thu Nov 22, 2018 2:39 pm
- Forum: C++ Development
- Topic: wxThread Kill()
- Replies: 48
- Views: 7007
Re: wxThread Kill()
You can only Wait() for joined threads. Detached threads are "fire and forget" as they destroy themselves. You can: 1) just ignore it and terminate the application after calling Destroy() (not recommended) 2) wait a fixed amount of time (e.g. 1 second) after calling Destroy(). If the thre...
- Wed Nov 21, 2018 2:59 pm
- Forum: C++ Development
- Topic: wxThread Kill()
- Replies: 48
- Views: 7007
Re: wxThread Kill()
I am calling TestDestroy() and the thread terminates, but the main thread is not waiting for it to terminate.
- Mon Nov 19, 2018 12:37 pm
- Forum: C++ Development
- Topic: wxThread Kill()
- Replies: 48
- Views: 7007
Re: wxThread Kill()
Can you explain in more detail what you want to achieve? Especially: While the background thread is working, can the user continue to use the application in every way? Since the background thread is working all the time the main thread exists, the user should still be able to use the application in...
- Fri Nov 16, 2018 4:13 pm
- Forum: C++ Development
- Topic: wxThread Kill()
- Replies: 48
- Views: 7007
Re: wxThread Kill()
Looks like the timer is not a perfect solution. I tried it, but in some situations it seems to behave like unsynchronized thread.
- Tue Nov 13, 2018 4:00 pm
- Forum: C++ Development
- Topic: wxThread Kill()
- Replies: 48
- Views: 7007
Re: wxThread Kill()
I am not fearing pointers, but I hate to use them because they can produce memory leaks sometimes and they (memleaks) are really hard to find out. I see your point and I hate memory leaks, too. In this case though, you are quite safe because you delete your pointer only once and only upon ending th...
- Tue Nov 13, 2018 1:12 pm
- Forum: C++ Development
- Topic: wxThread Kill()
- Replies: 48
- Views: 7007
Re: wxThread Kill()
Posibly I misunderstood something, I need to wait for the thread only at the end the rest it should run in background parallel to the main thread. Yes, that is what I tried to tell you with the examples I provided for you. You have to wait for your joined thread right after you ran it! (and not at ...
- Fri Nov 09, 2018 4:27 pm
- Forum: C++ Development
- Topic: wxThread Kill()
- Replies: 48
- Views: 7007
Re: wxThread Kill()
Hi, So all in all the reason for MT is to not block UI for the time calculation is done? How much time does it take to perform it? Thank you. I have done no performance tests, since it is not limited to some special PC. Also since results from background thread are not used by the main application ...
- Fri Nov 09, 2018 4:04 pm
- Forum: C++ Development
- Topic: wxThread Kill()
- Replies: 48
- Views: 7007
Re: wxThread Kill()
Hi, Can you do the calculation on timer? Or this calculation absolutely have to be done in background and your program will use the results of the calculation even in the middle of the processing? Thank you. P.S.: What I mean is this: Let's say you thread will add the number 2 to the parameter, lik...
- Fri Nov 09, 2018 1:34 pm
- Forum: C++ Development
- Topic: wxThread Kill()
- Replies: 48
- Views: 7007
Re: wxThread Kill()
If you have only one joinable thread, and you must wait until it finishes, how is this different from not using threads at all? IMHO, joinable threads may be useful if you fire several at once. I consider this case as a way to speed up tasks that can be parallelized, and the app can't continue unti...
- Fri Nov 09, 2018 12:59 pm
- Forum: C++ Development
- Topic: Internationalisation
- Replies: 22
- Views: 5354
Re: Internationalisation
After hours of reading documentation and triing diferent stuff, looks like I finaly solve the problem: wxTranslations *t=new wxTranslations(); t->SetLanguage(lng); wxLocale::AddCatalogLookupPathPrefix("."); t->AddCatalog("translations"); wxTranslations::Set(t); lng is the int val...
- Fri Nov 09, 2018 11:50 am
- Forum: C++ Development
- Topic: wxGetApp eeror
- Replies: 6
- Views: 1828
Re: wxGetApp eeror
Hi, Usually people start with minimal sample. But in general - if you know what you are looking for, you go to the documentation first, then the sample, and only then go to search the web (Google). That should be the standard course of actions for every issue related to wxWidgets. Thank you. I agre...