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

StackOverflow https://stackoverflow.com/questions/21456833

  •  05-10-2022
  •  | 
  •  

Question

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
}
Was it helpful?

Solution

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   
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top