develooper Front page | perl.wxperl.users | Postings from August 2008

Blocking the app from a secondary thread?

From:
Octavian Rasnita
Date:
August 29, 2008 10:58
Subject:
Blocking the app from a secondary thread?
Message ID:
D0880F2BADC646369C41BAD9F2AAC791@teddy
Hi,

I've seen that if I try to create a Wx::Dialog from a secondary thread, it 
breaks the app, but if I create a Wx::MessageBox it works fine.
So I tried to use a Wx::GetMultipleChoices. It displays well the dialog and 
it returns well the results, but if another thread tries to update the main 
window, in that moment the application crashes.

I don't know why Wx::GetMultipleChoices doesn't work as well as 
Wx::MessageBox, because they are created the same (without ->new().

I see that if I want to block other threads to update the GUI, I must use

wxMutexGuiEnter();
and
wxMutexGuiLeave();

I have tried to use

Wx::MutexGUIEnter();

my @result = Wx::GetMultipleChoices("Message", "Title", ['aa','bb','cc']);
print "@result\n";

Wx::MutexGUILeave();

but it didn't displayed the dialog and it printed the following error 
message:

Error while autoloading 'Wx::MutexGUIEnter' at Informatos/Server.pm line 84

I think Wx::MutexGUIEnter should work with WxPerl because I haven't seen any 
notice telling that it doesn't work.

I have also read that:

"Note that under GTK, no creation of top-level windows is allowed in any 
thread but the main one."

So I assume under Win32 it should work.

"This function is only defined on platforms which support preemptive 
threads."

But I don't know, is Win32 such a platform?

If it is, please tell me what am I doing wrong.

Thank you.

Octavian




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About