Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas N <andreas@mono-cvs.ximian.com>2003-07-10 20:55:22 +0400
committerAndreas N <andreas@mono-cvs.ximian.com>2003-07-10 20:55:22 +0400
commit74cee0a54f52a5a450fbde8cf48f585827adb512 (patch)
treeb0c68ef9e583526a084e8533dae5032be4c30c04 /mcs/class/System/Microsoft.Win32
parentc5c295d0b42b7ac3a207e9facbda9ae189ce9868 (diff)
2003-07-10 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
* SystemEvents.cs: Implemented preliminary timer support, added private constructor, fixed events svn path=/trunk/mcs/; revision=16106
Diffstat (limited to 'mcs/class/System/Microsoft.Win32')
-rw-r--r--mcs/class/System/Microsoft.Win32/ChangeLog4
-rw-r--r--mcs/class/System/Microsoft.Win32/SystemEvents.cs243
2 files changed, 141 insertions, 106 deletions
diff --git a/mcs/class/System/Microsoft.Win32/ChangeLog b/mcs/class/System/Microsoft.Win32/ChangeLog
index 78c9eaca5e5..166c27d2a89 100644
--- a/mcs/class/System/Microsoft.Win32/ChangeLog
+++ b/mcs/class/System/Microsoft.Win32/ChangeLog
@@ -1,3 +1,7 @@
+2003-07-10 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * SystemEvents.cs: Implemented preliminary timer support, added private constructor, fixed events
+
2003-06-12 Duncan Mak <duncan@ximian.com>
* UserPreferenceChangedEventArgs.cs
diff --git a/mcs/class/System/Microsoft.Win32/SystemEvents.cs b/mcs/class/System/Microsoft.Win32/SystemEvents.cs
index 1abc7aedf83..b0c43909d98 100644
--- a/mcs/class/System/Microsoft.Win32/SystemEvents.cs
+++ b/mcs/class/System/Microsoft.Win32/SystemEvents.cs
@@ -1,110 +1,141 @@
-//
-// SystemEvents.cs
-//
-// Author:
-// Johannes Roith (johannes@jroith.de)
-//
-// (C) 2002 Johannes Roith
-//
+//
+// Microsoft.Win32.SystemEvents.cs
+//
+// Authors:
+// Johannes Roith (johannes@jroith.de)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+// (C) 2002 Johannes Roith
+// (C) 2003 Andreas Nahr
+//
+
+using System;
+using System.Timers;
+using System.Collections;
-namespace Microsoft.Win32 {
- /// <summary>
- /// </summary>
-public sealed class SystemEvents {
-
- [MonoTODO]
- public static void InvokeOnEventsThread(System.Delegate method)
- {
- throw new System.NotImplementedException ();
- }
-
-
-
- [MonoTODO]
- public static event System.EventHandler DisplaySettingsChanged {
- add { throw new System.NotImplementedException ();}
- remove { throw new System.NotImplementedException ();}
- }
-
-
- [MonoTODO]
- public static event System.EventHandler EventsThreadShutdown {
- add { throw new System.NotImplementedException ();}
- remove { throw new System.NotImplementedException ();}
- }
-
-
- [MonoTODO]
- public static event System.EventHandler InstalledFontsChanged {
- add { throw new System.NotImplementedException ();}
- remove { throw new System.NotImplementedException ();}
- }
-
-
- [MonoTODO]
- public static event System.EventHandler LowMemory {
- add { throw new System.NotImplementedException ();}
- remove { throw new System.NotImplementedException ();}
- }
-
-
- [MonoTODO]
- public static event System.EventHandler PaletteChanged {
- add { throw new System.NotImplementedException ();}
- remove { throw new System.NotImplementedException ();}
- }
-
-
- [MonoTODO]
- public static event PowerModeChangedEventHandler PowerModeChanged {
- add { throw new System.NotImplementedException ();}
- remove { throw new System.NotImplementedException ();}
- }
-
-
- [MonoTODO]
- public static event SessionEndedEventHandler SessionEnded {
- add { throw new System.NotImplementedException ();}
- remove { throw new System.NotImplementedException ();}
- }
-
-
- [MonoTODO]
- public static event System.EventHandler SessionEnding {
- add { throw new System.NotImplementedException ();}
- remove { throw new System.NotImplementedException ();}
- }
-
-
- [MonoTODO]
- public static event System.EventHandler TimeChanged {
- add { throw new System.NotImplementedException ();}
- remove { throw new System.NotImplementedException ();}
- }
-
-
- [MonoTODO]
- public static event UserPreferenceChangedEventHandler TimerElapsed {
- add { throw new System.NotImplementedException ();}
- remove { throw new System.NotImplementedException ();}
- }
-
-
- [MonoTODO]
- public static event UserPreferenceChangedEventHandler UserPreferenceChanged {
- add { throw new System.NotImplementedException ();}
- remove { throw new System.NotImplementedException ();}
- }
-
-
- [MonoTODO]
- public static event UserPreferenceChangingEventHandler UserPreferenceChanging {
- add { throw new System.NotImplementedException ();}
- remove { throw new System.NotImplementedException ();}
- }
-
-
-}
+namespace Microsoft.Win32
+{
+ public sealed class SystemEvents
+ {
+ private static Hashtable TimerStore = new Hashtable ();
+
+ private SystemEvents ()
+ {
+ }
+
+ // You can use timers using the CreateTimer, KillTimer methods and the Timerelapsed event
+ // This is only a partial solution, as it only works in managed code.
+ // TODO implement this on OS level
+ // Till done this solution should work if you are only using the mentioned members
+
+ public static IntPtr CreateTimer (int interval)
+ {
+ Guid Ident = Guid.NewGuid ();
+ int IdentValue = Ident.GetHashCode ();
+ Timer t = new System.Timers.Timer (interval);
+ t.Elapsed += new ElapsedEventHandler (InternalTimerElapsed);
+ TimerStore.Add (IdentValue, t);
+ return new IntPtr (IdentValue);
+ }
+
+ public static void KillTimer (IntPtr timerId)
+ {
+ Timer t = (Timer) TimerStore[timerId.GetHashCode()];
+ t.Stop ();
+ t.Elapsed -= new ElapsedEventHandler (InternalTimerElapsed);
+ t.Dispose ();
+ TimerStore.Remove (timerId.GetHashCode());
+ }
+
+ private static void InternalTimerElapsed (object e, ElapsedEventArgs args)
+ {
+ if (TimerElapsed != null)
+ TimerElapsed (null, new TimerElapsedEventArgs (new IntPtr(0)));
+ }
+ [MonoTODO]
+ public static void InvokeOnEventsThread(Delegate method)
+ {
+ throw new System.NotImplementedException ();
+ }
+ [MonoTODO]
+ public static event System.EventHandler DisplaySettingsChanged
+ {
+ add { throw new System.NotImplementedException ();}
+ remove { throw new System.NotImplementedException ();}
+ }
+
+ [MonoTODO]
+ public static event System.EventHandler EventsThreadShutdown
+ {
+ add { throw new System.NotImplementedException ();}
+ remove { throw new System.NotImplementedException ();}
+ }
+
+ [MonoTODO]
+ public static event System.EventHandler InstalledFontsChanged
+ {
+ add { throw new System.NotImplementedException ();}
+ remove { throw new System.NotImplementedException ();}
+ }
+
+ [MonoTODO]
+ public static event System.EventHandler LowMemory
+ {
+ add { throw new System.NotImplementedException ();}
+ remove { throw new System.NotImplementedException ();}
+ }
+
+ [MonoTODO]
+ public static event System.EventHandler PaletteChanged
+ {
+ add { throw new System.NotImplementedException ();}
+ remove { throw new System.NotImplementedException ();}
+ }
+
+ [MonoTODO]
+ public static event PowerModeChangedEventHandler PowerModeChanged
+ {
+ add { throw new System.NotImplementedException ();}
+ remove { throw new System.NotImplementedException ();}
+ }
+
+ [MonoTODO]
+ public static event SessionEndedEventHandler SessionEnded
+ {
+ add { throw new System.NotImplementedException ();}
+ remove { throw new System.NotImplementedException ();}
+ }
+
+ [MonoTODO]
+ public static event SessionEndingEventHandler SessionEnding
+ {
+ add { throw new System.NotImplementedException ();}
+ remove { throw new System.NotImplementedException ();}
+ }
+
+ [MonoTODO]
+ public static event System.EventHandler TimeChanged
+ {
+ add { throw new System.NotImplementedException ();}
+ remove { throw new System.NotImplementedException ();}
+ }
+
+ public static event TimerElapsedEventHandler TimerElapsed;
+
+ [MonoTODO]
+ public static event UserPreferenceChangedEventHandler UserPreferenceChanged
+ {
+ add { throw new System.NotImplementedException ();}
+ remove { throw new System.NotImplementedException ();}
+ }
+
+ [MonoTODO]
+ public static event UserPreferenceChangingEventHandler UserPreferenceChanging
+ {
+ add { throw new System.NotImplementedException ();}
+ remove { throw new System.NotImplementedException ();}
+ }
+ }
}