Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 25th, 2012  |  syntax: None  |  size: 0.99 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #getting no exceptions from this, but I don't see "TESTING" in terminal
  2.  
  3. class InterruptEvent < Wx::CommandEvent
  4.         INTERRUPT_EVENT = Wx::EvtHandler.register_class(self, nil, "doInterruptEvent", 1)
  5.         def initialize(*args)
  6.                
  7.         end
  8.        
  9.         def doInterruptEvent
  10.                 garbage_var = 0
  11.                 puts "TESTING" #Doesn't show in terminal
  12.         end
  13. end
  14.  
  15. class MainApp < Wx::App
  16.         def on_init
  17. #               self.gc_stress(100) # Force garbage collector to run ten times a second.
  18.                 $mutex.synchronize {
  19.                         $interruptEvent = InterruptEvent.new
  20.                         $loginFrame = LoginFrame.new
  21.                         $loginFrame.show
  22.                 }
  23.         end
  24. end
  25.  
  26. def startUpLoginApp
  27.         Thread.start() do
  28.                 begin
  29.                         $theMainApp = MainApp.new
  30.                         Thread.start() do
  31.                                 sleep 3
  32.                                 loop {
  33.                                         sleep 0.05
  34.                                         Wx::EvtHandler.add_pending_event(INTERRUPT_EVENT)
  35.                                 }
  36.                         end
  37.                         $theMainApp.main_loop
  38.                 rescue => e
  39.                         puts "EXCEPTION (WxApp Thread): "
  40.                         puts "#{e.backtrace.delete_at(0)}: #{e} (#{e.class})"
  41.                         e.backtrace.each do |line|; puts line; end
  42.                         sleep 10
  43.                 end
  44.         end
  45. end