X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2Fcorlib%2FSystem.Threading%2FTimer.cs;h=d1546a8bfcaa80632664c766dd64e69f70977b22;hb=066284a9caebde26db0248f18bb6b4082e700c19;hp=dd32032436f9363d19827afc5e4df216edff9969;hpb=51927cb4192e9ab4ef42cfad8b8be638c0e615c8;p=mono.git diff --git a/mcs/class/corlib/System.Threading/Timer.cs b/mcs/class/corlib/System.Threading/Timer.cs index dd32032436f..d1546a8bfca 100644 --- a/mcs/class/corlib/System.Threading/Timer.cs +++ b/mcs/class/corlib/System.Threading/Timer.cs @@ -31,6 +31,7 @@ using System.Runtime.InteropServices; using System.Collections.Generic; using System.Collections; +using System.Runtime.CompilerServices; namespace System.Threading { @@ -153,7 +154,7 @@ namespace System.Threading return true; } } else { - nr = dueTime * TimeSpan.TicksPerMillisecond + DateTime.GetTimeMonotonic (); + nr = dueTime * TimeSpan.TicksPerMillisecond + GetTimeMonotonic (); } scheduler.Change (this, nr); @@ -165,10 +166,19 @@ namespace System.Threading if (notifyObject == null) throw new ArgumentNullException ("notifyObject"); Dispose (); - NativeEventCalls.SetEvent_internal (notifyObject.Handle); + NativeEventCalls.SetEvent (notifyObject.SafeWaitHandle); return true; } + // extracted from ../../../../external/referencesource/mscorlib/system/threading/timer.cs + internal void KeepRootedWhileScheduled() + { + } + + // TODO: Environment.TickCount should be enough as is everywhere else + [MethodImplAttribute(MethodImplOptions.InternalCall)] + static extern long GetTimeMonotonic (); + sealed class TimerComparer : IComparer { public int Compare (object x, object y) { @@ -323,7 +333,7 @@ namespace System.Threading var new_time = new List (512); while (true) { int ms_wait = -1; - long ticks = DateTime.GetTimeMonotonic (); + long ticks = GetTimeMonotonic (); lock (this) { changed.Reset (); //PrintList (); @@ -337,14 +347,14 @@ namespace System.Threading list.RemoveAt (i); count--; i--; - ThreadPool.QueueWorkItem (TimerCB, 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)); if (no_more) { timer.next_run = Int64.MaxValue; } else { - timer.next_run = DateTime.GetTimeMonotonic () + TimeSpan.TicksPerMillisecond * timer.period_ms; + timer.next_run = GetTimeMonotonic () + TimeSpan.TicksPerMillisecond * timer.period_ms; new_time.Add (timer); } } @@ -371,7 +381,7 @@ namespace System.Threading //PrintList (); ms_wait = -1; if (min_next_run != Int64.MaxValue) { - long diff = (min_next_run - DateTime.GetTimeMonotonic ()) / TimeSpan.TicksPerMillisecond; + long diff = (min_next_run - GetTimeMonotonic ()) / TimeSpan.TicksPerMillisecond; if (diff > Int32.MaxValue) ms_wait = Int32.MaxValue - 1; else {