System 1.0.5000.0 2.0.0.0 4.0.0.0 System.Object The class provides the ability to respond to specific types of system events. When a system event is raised, any delegates attached to the event are called using the thread that monitors for system events. Therefore, you should make any calls from your event handlers thread-safe. If you need to call a system event that is not exposed as a member of this class, you can use the method. Do not perform time-consuming processing on the thread that raises a system event handler because it might prevent other applications from functioning. Some system events might not be raised on windowsver. Be sure to verify that your application works as expected on windowsver. Provides access to system event notifications. This class cannot be inherited. Method 1.0.5000.0 2.0.0.0 4.0.0.0 System.IntPtr To be added. Creates a new window timer associated with the system events window. The ID of the new timer. Specifies the interval between timer notifications, in milliseconds. Event 1.0.5000.0 2.0.0.0 4.0.0.0 System.MonoTODO System.EventHandler Because this is a static event, you must detach your event handlers when your application is disposed, or memory leaks will result. Occurs when the user changes the display settings. Event 2.0.0.0 4.0.0.0 System.MonoTODO("Currently does nothing on Mono") System.EventHandler Because this is a static event, you must detach your event handlers when your application is disposed, or memory leaks will result. Occurs when the display settings are changing. Event 1.0.5000.0 2.0.0.0 4.0.0.0 System.MonoTODO("Currently does nothing on Mono") System.EventHandler This event is raised as the thread that listens for system events is about to be terminated. System event delegates are invoked using the thread that listens for system events. Because this is a static event, you must detach your event handlers when your application is disposed, or memory leaks will result. Occurs before the thread that listens for system events is terminated. Event 1.0.5000.0 2.0.0.0 4.0.0.0 System.MonoTODO("Currently does nothing on Mono") System.EventHandler Because this is a static event, you must detach your event handlers when your application is disposed, or memory leaks will result. Occurs when the user adds fonts to or removes fonts from the system. Method 1.0.5000.0 2.0.0.0 4.0.0.0 System.MonoTODO System.Void You can use this method any time that you need to handle a system event that is not exposed otherwise by the class. When you call this method, the specified delegate will be invoked by the thread that your application is using to process system events. Invokes the specified delegate using the thread that listens for system events. A delegate to invoke using the thread that listens for system events. Method 1.0.5000.0 2.0.0.0 4.0.0.0 System.Void To be added. Terminates the timer specified by the given id. The ID of the timer to terminate. Event 1.0.5000.0 2.0.0.0 4.0.0.0 System.ComponentModel.Browsable(false) System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never) System.MonoTODO("Currently does nothing on Mono") System.Obsolete("") System.EventHandler This event wraps the WM_COMPACTING message. This message is sent to all top-level windows when the system detects more than 12.5 percent of system time over a 30- to 60-second interval is being spent compacting memory. This indicates that system memory is low. This event is only raised if the message pump is running. In a Windows service, unless a hidden form is used or the message pump has been started manually, this event will not be raised. For a code example that shows how to handle system events by using a hidden form in a Windows service, see the class. Because this is a static event, you must detach your event handlers when your application is disposed, or memory leaks will result. Occurs when the system is running out of available RAM. Event 1.0.5000.0 2.0.0.0 4.0.0.0 System.MonoTODO("Currently does nothing on Mono") System.EventHandler This event is only raised if the message pump is running. In a Windows service, unless a hidden form is used or the message pump has been started manually, this event will not be raised. For a code example that shows how to handle system events by using a hidden form in a Windows service, see the class. Because this is a static event, you must detach your event handlers when your application is disposed, or memory leaks will result. Occurs when the user switches to an application that uses a different palette. Event 1.0.5000.0 2.0.0.0 4.0.0.0 System.MonoTODO("Currently does nothing on Mono") Microsoft.Win32.PowerModeChangedEventHandler This event is only raised if the message pump is running. In a Windows service, unless a hidden form is used or the message pump has been started manually, this event will not be raised. For a code example that shows how to handle system events by using a hidden form in a Windows service, see the class. Because this is a static event, you must detach your event handlers when your application is disposed, or memory leaks will result. Occurs when the user suspends or resumes the system. Event 1.0.5000.0 2.0.0.0 4.0.0.0 System.MonoTODO("Currently does nothing on Mono") Microsoft.Win32.SessionEndedEventHandler This event is only raised if the message pump is running. In a Windows service, unless a hidden form is used or the message pump has been started manually, this event will not be raised. For a code example that shows how to handle system events by using a hidden form in a Windows service, see the class. Because this is a static event, you must detach your event handlers when your application is disposed, or memory leaks will result. Occurs when the user is logging off or shutting down the system. Event 1.0.5000.0 2.0.0.0 4.0.0.0 System.MonoTODO("Currently does nothing on Mono") Microsoft.Win32.SessionEndingEventHandler This is a cancelable event. Setting the property to true will request that the session continues to run. It provides no guarantee that the session will not end. If you are using in a Windows form to detect a system logoff or reboot, there is no deterministic way to decide whether the event will fire before this event. If you want to perform some special tasks before is fired, you need to ensure that fires before . To do this, you need to trap the WM_QUERYENDSESSION in the form by overriding the WndProc function. This example demonstrates how to do this. Private Shared WM_QUERYENDSESSION As Integer = &H11 Private Shared systemShutdown As Boolean = False Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) If m.Msg = WM_QUERYENDSESSION Then MessageBox.Show("queryendsession: this is a logoff, shutdown, or reboot") systemShutdown = True End If ' If this is WM_QUERYENDSESSION, the closing event should be raised in the base WndProc. MyBase.WndProc(m) End Sub 'WndProc Private Sub Form1_Closing(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing If (systemShutdown) Then ' Reset the variable because the user might cancel the shutdown. systemShutdown = False If (System.Windows.Forms.DialogResult.Yes = _ MessageBox.Show("My application", "Do you want to save your work before logging off?", MessageBoxButtons.YesNo)) Then e.Cancel = True Else e.Cancel = False End If End If End Sub private static int WM_QUERYENDSESSION = 0x11; private static bool systemShutdown = false; protected override void WndProc(ref System.Windows.Forms.Message m) { if (m.Msg==WM_QUERYENDSESSION) { MessageBox.Show("queryendsession: this is a logoff, shutdown, or reboot"); systemShutdown = true; } // If this is WM_QUERYENDSESSION, the closing event should be // raised in the base WndProc. base.WndProc(ref m); } //WndProc private void Form1_Closing( System.Object sender, System.ComponentModel.CancelEventArgs e) { if (systemShutdown) // Reset the variable because the user might cancel the // shutdown. { systemShutdown = false; if (DialogResult.Yes==MessageBox.Show("My application", "Do you want to save your work before logging off?", MessageBoxButtons.YesNo)) { e.Cancel = true; } else { e.Cancel = false; } } } Console applications do not raise the event. This event is only raised if the message pump is running. In a Windows service, unless a hidden form is used or the message pump has been started manually, this event will not be raised. For a code example that shows how to handle system events by using a hidden form in a Windows service, see the class. Because this is a static event, you must detach your event handlers when your application is disposed, or memory leaks will result. Occurs when the user is trying to log off or shut down the system. Event 2.0.0.0 4.0.0.0 System.MonoTODO("Currently does nothing on Mono") Microsoft.Win32.SessionSwitchEventHandler This event is only raised if the message pump is running. In a Windows service, unless a hidden form is used or the message pump has been started manually, this event will not be raised. For a code example that shows how to handle system events by using a hidden form in a Windows service, see the class. Because this is a static event, you must detach your event handlers when your application is disposed, or memory leaks will result. Occurs when the currently logged-in user has changed. Event 1.0.5000.0 2.0.0.0 4.0.0.0 System.MonoTODO("Currently does nothing on Mono") System.EventHandler This event is only raised if the message pump is running. In a Windows service, unless a hidden form is used or the message pump has been started manually, this event will not be raised. For a code example that shows how to handle system events by using a hidden form in a Windows service, see the class. Because this is a static event, you must detach your event handlers when your application is disposed, or memory leaks will result. Occurs when the user changes the time on the system clock. Event 1.0.5000.0 2.0.0.0 4.0.0.0 Microsoft.Win32.TimerElapsedEventHandler This event is only raised if the message pump is running. In a Windows service, unless a hidden form is used or the message pump has been started manually, this event will not be raised. For a code example that shows how to handle system events by using a hidden form in a Windows service, see the class. Because this is a static event, you must detach your event handlers when your application is disposed, or memory leaks will result. Occurs when a windows timer interval has expired. Event 1.0.5000.0 2.0.0.0 4.0.0.0 System.MonoTODO("Currently does nothing on Mono") Microsoft.Win32.UserPreferenceChangedEventHandler This event is only raised if the message pump is running. In a Windows service, unless a hidden form is used or the message pump has been started manually, this event will not be raised. For a code example that shows how to handle system events by using a hidden form in a Windows service, see the class. Because this is a static event, you must detach your event handlers when your application is disposed, or memory leaks will result. Occurs when a user preference has changed. Event 1.0.5000.0 2.0.0.0 4.0.0.0 System.MonoTODO("Currently does nothing on Mono") Microsoft.Win32.UserPreferenceChangingEventHandler This event is only raised if the message pump is running. In a Windows service, unless a hidden form is used or the message pump has been started manually, this event will not be raised. For a code example that shows how to handle system events by using a hidden form in a Windows service, see the class. Because this is a static event, you must detach your event handlers when your application is disposed, or memory leaks will result. Occurs when a user preference is changing.