From: "Morris, Chris" Date: 2001-10-27T01:41:59+09:00 Subject: [ruby-talk:23473] Threading WIN32OLE_EVENT.message_loop I'm able to run the WIN32OLE_EVENT sample. But I'm working on code that will drive IE for acceptance tests and I need my code to keep running while, I assume, another thread handles the WIN32OLE_EVENT.message_loop. How would I modify the example to allow me to add navigate calls from the code itself? Here's the original: require 'win32ole' $urls = [] def navigate(url) $urls << url end def stop_msg_loop puts "IE has exited..." throw :done end def default_handler(event, *args) case event when "BeforeNavigate" puts "Now Navigating to #{args[0]}..." end end ie = WIN32OLE.new('InternetExplorer.Application') ie.visible = TRUE ie.gohome ev = WIN32OLE_EVENT.new(ie, 'DWebBrowserEvents') ev.on_event {|*args| default_handler(*args)} ev.on_event("NavigateComplete") {|url| navigate(url)} ev.on_event("Quit") {|*args| stop_msg_loop} catch(:done) { loop { WIN32OLE_EVENT.message_loop } } # how can I thread the above to add navigate calls here? # ie.navigate('http://www.rubycentral.com') # then this can't execute until the thread is done puts "You Navigated to the following URLs: " $urls.each_with_index do |url, i| puts "(#{i+1}) #{url}" end Chris