Zane
Zane

Reputation: 193

Jruby+Swt. How to implement continuously appending to the scrollable multiline text in the thread

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

Answers (1)

Zane
Zane

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

Related Questions