Calling custom wxDialog's "ShowModal()" from secondary thread Topic is solved
Calling custom wxDialog's "ShowModal()" from secondary thread
I have two threads , on thread exists so that the UI doesnt get blocked when executing events , and another thread exists to execute the events.
I am using wxWidgets with C++ /CLI and I am using a .NET thread.
Before you say "YoU sHoUlDn'T cAlL gUI mEtHoDs FrOm A sEcOnDaRy ThReAd" , the wxMessageDialog's "ShowModal()" works in a seperate thread (Even though the thread is a .NET thread), which means my Custom Message Dialog should work too.
Also please don't give me complicated wxThread stuff and non-working code, if the wxMessageDialog works without me having to create a wxThread class then my dialog also shouldn't have to create its own wxThread class.
I just want to know exactly how the wxMessageDialog's "ShowModal()" can be called from a secondary thread.
The custom dialog's widgets do work in the thread though, but the debug alert thing shows up when using it. And when using wxMessageDialog in the thread, the debug alert message doesn't show up
I've tried surrounding the "ShowModal()" call with wxMutexGuiEnter(); and wxMutexGuiLeave(); even that didnt work
I am using wxWidgets with C++ /CLI and I am using a .NET thread.
Before you say "YoU sHoUlDn'T cAlL gUI mEtHoDs FrOm A sEcOnDaRy ThReAd" , the wxMessageDialog's "ShowModal()" works in a seperate thread (Even though the thread is a .NET thread), which means my Custom Message Dialog should work too.
Also please don't give me complicated wxThread stuff and non-working code, if the wxMessageDialog works without me having to create a wxThread class then my dialog also shouldn't have to create its own wxThread class.
I just want to know exactly how the wxMessageDialog's "ShowModal()" can be called from a secondary thread.
The custom dialog's widgets do work in the thread though, but the debug alert thing shows up when using it. And when using wxMessageDialog in the thread, the debug alert message doesn't show up
I've tried surrounding the "ShowModal()" call with wxMutexGuiEnter(); and wxMutexGuiLeave(); even that didnt work
Re: Calling custom wxDialog's "ShowModal()" from secondary thread
Hi,
Please do not cross-post on different forums - it makes helping you harder.
Please check the SO as I just replied there .
Thank you.
Please do not cross-post on different forums - it makes helping you harder.
Please check the SO as I just replied there .
Thank you.
Re: Calling custom wxDialog's "ShowModal()" from secondary thread
Hi,
Yes, and?
Thank you.
Yes, and?
Thank you.
Re: Calling custom wxDialog's "ShowModal()" from secondary thread
Don't be mad
I need threads, for a generic progress dialog, while im executing my function I need to update the progress dialog , but the progress dialog is blocked since i'm executing a function, thats why I need threads.
I can't find any alternative to this
I need threads, for a generic progress dialog, while im executing my function I need to update the progress dialog , but the progress dialog is blocked since i'm executing a function, thats why I need threads.
I can't find any alternative to this
Re: Calling custom wxDialog's "ShowModal()" from secondary thread
Hi,
No you don't.
wx{Generic}ProgressDialog is using thread internally.
All you do is to call update from your code.
Check dialogs sample/documentation for more details.
Thank you.
No you don't.
wx{Generic}ProgressDialog is using thread internally.
All you do is to call update from your code.
Check dialogs sample/documentation for more details.
Thank you.
Re: Calling custom wxDialog's "ShowModal()" from secondary thread
Really ?!! last time I used it , it was blocked
Re: Calling custom wxDialog's "ShowModal()" from secondary thread
Okay , wxgenericProgressDialog is definitely not using threading.
I compiled this with wxWidgets 3.1.5
Here is my test to see if it is has internal threading :
As well as having no threading, the progress dialog slows down the entire program
Every 1.5 seconds , I am updating the dialog.
When using threads the dialog seems to be working and everything seems fine.
Making the progress dialog smooth also doesnt work. I'm confused since your saying its supposed to work but its clearly not
When I move the dialog around, it takes at least a second for the dialog to move to its new position. Is this a bug in 3.1.5 that is fixed in 3.1.6 ?? vcpkg only gives me version 3.1.5 of wxWidgets.
Can you give a line number of where the wxGenericProgressDialog is tested in the samples. there are thousands of lines.
Edit :
Also I was thinking that Instead of having threads that update the GUI, I will be sending events to the main thread from the secondary threads that update the GUI. I could also use CallAfter() and call a method that would show my custom dialog.
But In C++ /CLI when I declare events I get a inner C++ /CLI exception :
But In C++ everything works fine.
Edit 2 :
Another Idea I came up with , since progress dialogs have there own internal thread, calling the Update() method on a secondary own thread shouldn't be a problem since its already using an internal thread to so.
I compiled this with wxWidgets 3.1.5
Here is my test to see if it is has internal threading :
As well as having no threading, the progress dialog slows down the entire program
Every 1.5 seconds , I am updating the dialog.
When using threads the dialog seems to be working and everything seems fine.
Making the progress dialog smooth also doesnt work. I'm confused since your saying its supposed to work but its clearly not
When I move the dialog around, it takes at least a second for the dialog to move to its new position. Is this a bug in 3.1.5 that is fixed in 3.1.6 ?? vcpkg only gives me version 3.1.5 of wxWidgets.
Can you give a line number of where the wxGenericProgressDialog is tested in the samples. there are thousands of lines.
Edit :
Also I was thinking that Instead of having threads that update the GUI, I will be sending events to the main thread from the secondary threads that update the GUI. I could also use CallAfter() and call a method that would show my custom dialog.
But In C++ /CLI when I declare events I get a inner C++ /CLI exception :
System.TypeInitializationException: 'The type initializer for '<Module>' threw an exception.'
But In C++ everything works fine.
Edit 2 :
Another Idea I came up with , since progress dialogs have there own internal thread, calling the Update() method on a secondary own thread shouldn't be a problem since its already using an internal thread to so.
Re: Calling custom wxDialog's "ShowModal()" from secondary thread
Alright , I have figured out what to do. Instead of calling the GUI methods directory, from my thread I am calling "CallAfter()" to a function that will call the GUI methods from the main thread. That way I'm not running any GUI methods in a thread.
Last edited by ibrahim on Wed May 18, 2022 12:07 pm, edited 1 time in total.
Re: Calling custom wxDialog's "ShowModal()" from secondary thread
Hi,
1. Why do you need generic version?
2. Is slowing down the app reproducible in dialogs sample?
Thank you.
1. Why do you need generic version?
2. Is slowing down the app reproducible in dialogs sample?
Thank you.
Re: Calling custom wxDialog's "ShowModal()" from secondary thread
I can't remember why I needed a generic progress dialog. But I did need it.
I will try to reproduce it
BTW can you please read my message above.
I will try to reproduce it
BTW can you please read my message above.
Re: Calling custom wxDialog's "ShowModal()" from secondary thread
Hi,
1. My question was: why did you need it vs wxProgressDialog. What is the difference between native and general so that you prefer the latter.
2. Yes, I did. And it is a good solution.
3. Please try to reproduce the behavior in the sample. If you can - submit it on wxWidgets issues.
Thank you.
1. My question was: why did you need it vs wxProgressDialog. What is the difference between native and general so that you prefer the latter.
2. Yes, I did. And it is a good solution.
3. Please try to reproduce the behavior in the sample. If you can - submit it on wxWidgets issues.
Thank you.
Re: Calling custom wxDialog's "ShowModal()" from secondary thread
In your thread from two months ago you wanted to bind an event handler to the Cancel button.
Use the source, Luke!
Re: Calling custom wxDialog's "ShowModal()" from secondary thread
Oh Wait yeh now I remember