Search found 172 matches

by gtafan
Mon Dec 03, 2018 2:58 pm
Forum: C++ Development
Topic: wxThread and OpengL
Replies: 7
Views: 684

Re: wxThread and OpengL

Hi, Accessing ANY GUI IN THE SECONDARY THREAD IS NOT SAFE AND WILL LEAD TO CRASJES!!!! It might work in one OS, or maybe 2 (if you are lucky), but generally in a cross-platform environment it is considered a VERY BAD PRACTICE!!! Thank you. What you mean by NOT SAFE? Not thread safe? Why should it b...
by gtafan
Wed Nov 28, 2018 2:56 pm
Forum: C++ Development
Topic: wxThread Kill()
Replies: 48
Views: 3384

Re: wxThread Kill()

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.
But wxCondition needs a mutex, that is not necesary for semaphor, but posibly I just understood everything wrong.
by gtafan
Tue Nov 27, 2018 2:49 pm
Forum: C++ Development
Topic: wxThread Kill()
Replies: 48
Views: 3384

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...
by gtafan
Fri Nov 23, 2018 12:22 pm
Forum: C++ Development
Topic: wxThread Kill()
Replies: 48
Views: 3384

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...
by gtafan
Thu Nov 22, 2018 3:21 pm
Forum: C++ Development
Topic: wxThread Kill()
Replies: 48
Views: 3384

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...
by gtafan
Thu Nov 22, 2018 2:39 pm
Forum: C++ Development
Topic: wxThread Kill()
Replies: 48
Views: 3384

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 thread calls T...
by gtafan
Wed Nov 21, 2018 2:59 pm
Forum: C++ Development
Topic: wxThread Kill()
Replies: 48
Views: 3384

Re: wxThread Kill()

I am calling TestDestroy() and the thread terminates, but the main thread is not waiting for it to terminate.
by gtafan
Mon Nov 19, 2018 12:37 pm
Forum: C++ Development
Topic: wxThread Kill()
Replies: 48
Views: 3384

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...
by gtafan
Fri Nov 16, 2018 4:13 pm
Forum: C++ Development
Topic: wxThread Kill()
Replies: 48
Views: 3384

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.
by gtafan
Tue Nov 13, 2018 4:00 pm
Forum: C++ Development
Topic: wxThread Kill()
Replies: 48
Views: 3384

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...
by gtafan
Tue Nov 13, 2018 1:12 pm
Forum: C++ Development
Topic: wxThread Kill()
Replies: 48
Views: 3384

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 ...
by gtafan
Fri Nov 09, 2018 4:27 pm
Forum: C++ Development
Topic: wxThread Kill()
Replies: 48
Views: 3384

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 ...
by gtafan
Fri Nov 09, 2018 4:04 pm
Forum: C++ Development
Topic: wxThread Kill()
Replies: 48
Views: 3384

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...
by gtafan
Fri Nov 09, 2018 1:34 pm
Forum: C++ Development
Topic: wxThread Kill()
Replies: 48
Views: 3384

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...
by gtafan
Fri Nov 09, 2018 12:59 pm
Forum: C++ Development
Topic: Internationalisation
Replies: 22
Views: 2632

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 value of the language. ...