def timer_helper(num_handlers=1, sleep_time=5, event_handlers=[], aTimer=None, error_margin=0.25):
 global COUNT
 global TIMER_HELPER_FINISHED
 COUNT = 0
 TIMER_HELPER_FINISHED = False
 try:
  if (aTimer == None):
   aTimer = System.Timers.Timer()
  for i in xrange(num_handlers):
   aTimer.Elapsed += System.Timers.ElapsedEventHandler(onTimedEvent)
  for handler in event_handlers:
   aTimer.Elapsed += System.Timers.ElapsedEventHandler(handler)
  aTimer.Interval = 100
  aTimer.Enabled = True
  sleep((sleep_time / 10.0))
  aTimer.Enabled = False
  sleep((sleep_time / 10.0))
  Assert((COUNT >= (int((sleep_time - (sleep_time * error_margin))) * (num_handlers + len(event_handlers)))), str(COUNT))
  Assert((COUNT <= (int((sleep_time + (sleep_time * error_margin))) * (num_handlers + len(event_handlers)))), str(COUNT))
 finally:
  TIMER_HELPER_FINISHED = True

def timer_helper ( num_handlers = 1 , sleep_time = 5 , event_handlers = [ ] , aTimer = None , error_margin = 0.25 ) : global COUNT global TIMER_HELPER_FINISHED COUNT = 0 TIMER_HELPER_FINISHED = False try : if ( aTimer == None ) : aTimer = System . Timers . Timer ( ) for i in xrange ( num_handlers ) : aTimer . Elapsed += System . Timers . ElapsedEventHandler ( onTimedEvent ) for handler in event_handlers : aTimer . Elapsed += System . Timers . ElapsedEventHandler ( handler ) aTimer . Interval = 100 aTimer . Enabled = True sleep ( ( sleep_time / 10.0 ) ) aTimer . Enabled = False sleep ( ( sleep_time / 10.0 ) ) Assert ( ( COUNT >= ( int ( ( sleep_time - ( sleep_time * error_margin ) ) ) * ( num_handlers + len ( event_handlers ) ) ) ) , str ( COUNT ) ) Assert ( ( COUNT <= ( int ( ( sleep_time + ( sleep_time * error_margin ) ) ) * ( num_handlers + len ( event_handlers ) ) ) ) , str ( COUNT ) ) finally : TIMER_HELPER_FINISHED = True
helper function used to test a single timer object under various conditions .