Reputation: 193
I need to implement gui which include multiline textbox to display logs.
I use "file-tail" gem to read the stream from file. I added swt thread asyncExec for managing gui elements asynchronously. But when I execute the code the gui is freezes and nothing puts to the text area.
@display.asyncExec {
File.open("path_to_the_file") do |log|
log.extend(File::Tail)
log.backward(10)
log.tail {|line|
@text_area.append line
}
end
}
Upvotes: 2
Views: 101
Reputation: 193
Worked example to this thread (Thanks @Baz)
threads = Thread.new {
File.open("path_to_the_file") do |log|
log.extend(File::Tail)
log.backward(10)
log.tail {|line|
@display.asyncExec {
@text_area.append line
}
}
end
}
Upvotes: 1