Don't eat exception from timer handler (this is system timer not SWF timer)
[mono.git] / mcs / class / corlib / System.Threading / Timer.cs
index 5d41f2388b99ae7df25e1e3c22cf0c96547df37e..63358776056a619725b9684e8ad5935200d1efc2 100644 (file)
@@ -29,6 +29,7 @@
 //
 
 using System.Runtime.InteropServices;
+using System.Collections.Generic;
 using System.Collections;
 
 namespace System.Threading
@@ -310,19 +311,16 @@ namespace System.Threading
                                return idx;
                        }
 
-                       static WaitCallback TimerCaller = new WaitCallback (TimerCB);
                        static void TimerCB (object o)
                        {
                                Timer timer = (Timer) o;
-                               try {
-                                       timer.callback (timer.state);
-                               } catch {}
+                               timer.callback (timer.state);
                        }
 
                        void SchedulerThread ()
                        {
                                Thread.CurrentThread.Name = "Timer-Scheduler";
-                               ArrayList new_time = new ArrayList (512);
+                               var new_time = new List<Timer> (512);
                                while (true) {
                                        int ms_wait = -1;
                                        long ticks = DateTime.GetTimeMonotonic ();
@@ -339,7 +337,7 @@ namespace System.Threading
                                                        list.RemoveAt (i);
                                                        count--;
                                                        i--;
-                                                       ThreadPool.UnsafeQueueUserWorkItem (TimerCaller, timer);
+                                                       ThreadPool.UnsafeQueueUserWorkItem (TimerCB, timer);
                                                        long period = timer.period_ms;
                                                        long due_time = timer.due_time_ms;
                                                        bool no_more = (period == -1 || ((period == 0 || period == Timeout.Infinite) && due_time != Timeout.Infinite));
@@ -354,7 +352,7 @@ namespace System.Threading
                                                // Reschedule timers with a new due time
                                                count = new_time.Count;
                                                for (i = 0; i < count; i++) {
-                                                       Timer timer = (Timer) new_time [i];
+                                                       Timer timer = new_time [i];
                                                        Add (timer);
                                                }
                                                new_time.Clear ();
@@ -388,7 +386,7 @@ namespace System.Threading
                                }
                        }
 
-                       void ShrinkIfNeeded (ArrayList list, int initial)
+                       void ShrinkIfNeeded (List<Timer> list, int initial)
                        {
                                int capacity = list.Capacity;
                                int count = list.Count;