Module: IronNails::View::Extensions::ThreadingSupport

Included in:
CommandSupport
Defined in:
lib/ironnails/view/xaml_proxy.rb

Instance Method Summary collapse

Instance Method Details

#on_new_thread(request, &b) ⇒ Object

Schedules this command to execute on a different thread and schedules the update of the view on the UI thread.



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/ironnails/view/xaml_proxy.rb', line 15

def on_new_thread(request, &b)
  cb = WaitCallback.new do
    begin
      # b.call
      blk = lambda { |obj| b.call }
      instance.dispatcher.begin_invoke(DispatcherPriority.normal, Action.of(System::Object).new(&blk), request.call )
    rescue Exception => e
      logger.error "#{e.message}"
      MessageBox.Show("There was a problem. #{e.message}")
    end
  end
  ThreadPool.queue_user_work_item cb
end

#on_ui_thread(element = :instance, &b) ⇒ Object



9
10
11
# File 'lib/ironnails/view/xaml_proxy.rb', line 9

def on_ui_thread(element=:instance, &b)
  send(element).dispatcher.begin_invoke(DispatcherPriority.normal, Action.new(&b))
end