Module: IronNails::View::Extensions::TimerSupport

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

Instance Method Summary collapse

Methods included from CommandSupport

#execute_command

Methods included from ThreadingSupport

#on_new_thread, #on_ui_thread

Instance Method Details

#add_timer(command) ⇒ Object



49
50
51
52
53
54
55
# File 'lib/ironnails/view/xaml_proxy.rb', line 49

def add_timer(command)
  command.view = self
  @attached = false
  instance_variable_set "@#{command.timer_name}", DispatcherTimer.new
  ti = get_timer_for command
  ti.interval = command.interval.to_timespan
end

#attached?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/ironnails/view/xaml_proxy.rb', line 66

def attached?
  !!@attached
end

#start_timer(command) ⇒ Object



57
58
59
60
61
62
63
64
# File 'lib/ironnails/view/xaml_proxy.rb', line 57

def start_timer(command)
  ti = get_timer_for command
  ti.tick do
    execute_command command if command.can_execute?
  end unless attached?
  @attached = true
  ti.start
end

#stop_timer(command) ⇒ Object



70
71
72
73
# File 'lib/ironnails/view/xaml_proxy.rb', line 70

def stop_timer(command)
  ti = get_timer_for command
  ti.stop
end