Hi,
I am writing a multi-threaded GUI in perl TK. Beside the main thread, the object of new thread is to monitor a server event queue and when ever there is a new event add it to a scrolled widget. At the same time the main thread might also add data to the scrolled widget as the scrolled widget is used for logging/status window.
When ever I try to add any event to the scrolled object from the child thread, my application dies with the following err:
Attempt to free non-existent shared string '_TK_RESULT_', Perl interpreter: 0x267d22c at C:/Perl/site/lib/Tk/Widget.pm
I would like to know if i can pass the object of scrolled widget or as a matter any hash reference to another thread in perl 5.10?
Your help is very much appreciated# Code to create scrolled widget my @CreateOptions = ['ROText', -label=>"Phone $Id", -labelPack => [-side => 'top', -expand + => 0, -anchor => 'w', -fill => 'y'], -wrap => 'none', -relief => 'gr +oove', -width=>$Width, -fg=>'white',-background=>"black", -scrollbars + => 'se']; @PackOptions = [-row=>0, -column=>0, -sticky=>"news", -columnspan=>7, +-rowspan=>19] $AFScroller->{LogScroller} = MW->Scrolled(@CreateOptions);# this is th +e object to scrolled widget $AFScroller->{LogScroller}->grid(@PackOptions); # code where new thread is created and scrolled widget object is used +to add event sub Activate { my $EventQueueTread = Thread->new(\&MonitorEventQueue, ($self, $Id) +); $EventQueueTread->detach; $AFScroller->{'LogScroller'}->insert('end',"xxx yyyyy"); $AFScroller->{'LogScroller'}->see('end'); $AFScroller->{'LogScroller'}->update; # do other stuff return 1; } sub MonitorEventQueue { START: $newevent = Checkeventqueue(); if ($newevent){ $AFScroller->{'LogScroller'}->insert('end',"$newevent");# this is w +hen application dies $AFScroller->{'LogScroller'}->see('end'); $AFScroller->{'LogScroller'}->update; } sleep 1; goto START; }
In reply to How to pass scrolled object to another thread by himanshujain_60
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |