Leser: 2
4 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/perl
use Tk;
use threads;
use threads::shared;
use IO::Pipe;
use IO::Handle;
$|=1;
my $news = 0;
share($news);
my $pipe = IO::Handle->new();
my $thread = threads->create(\&t,$pipe);
$pipe->fdopen($pipeFileno,'r');
my $win = MainWindow->new();
$lb = $win->Listbox()->pack();
$win->repeat(100,sub{ update($pipe,$lb)});
MainLoop;
sub t{
$pipe->fdopen($pipeFileno,'w');
while(1) {
print time()."\n";
print $pipe "a\n";
$news=1;
sleep(2);
}
}
sub update {
my ($pipe,$lb)=@_;
# $pipe->fdopen($pipeFileno,'r');
if($news){
print "update\n";
my $tmp=<$pipe>;
chomp($tmp);
print "insert: $tmp\n";
$lb->insert('end',$tmp);
$news=0;
}
}
4 Einträge, 1 Seite |