Monkeybars::TaskProcessor

Module that contains methods and classes used to take care of background task processing. Primarily this is the repaint_while method.

Public Class Methods

on_edt(&task) click to toggle source
# File lib/monkeybars/task_processor.rb, line 18
def on_edt(&task)
  if javax.swing.SwingUtilities.event_dispatch_thread?
    javax.swing.SwingUtilities.invoke_later Runnable.new(task)
  else
    javax.swing.SwingUtilities.invoke_and_wait Runnable.new(task)
  end
end
repaint_while(&task) click to toggle source

Passes the supplied block to a separate thread and returns the result of the executed block back to the caller. This should be utilized for long- running tasks that ought not tie up the Swing Event Dispatch Thread. Passing a block to this method will allow the GUI to remain responsive (and repaint), while the long-running task is executing.

# File lib/monkeybars/task_processor.rb, line 13
def repaint_while(&task)
  runner = Runner.new(&task)
  Worker.post(runner)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.