[C# Helper]
Index Books FAQ Contact About Rod
[Essential Algorithms, Second Edition]

[The Modern C# Challenge]

[WPF 3d, Three-Dimensional Graphics with WPF and C#]

[The C# Helper Top 100]

[Interview Puzzles Dissected]

[C# 24-Hour Trainer]

[Beginning Software Engineering]

[C# 5.0 Programmer's Reference]

[MCSD Certification Toolkit (Exam 70-483): Programming in C#]

Title: Suspend or hibernate the system in C#

[Suspend or hibernate the system in C#]

The Application.SetSuspendState method lets an application make the system suspend or hibernate. A suspended system enters a low power mode. A hibernating system saves its memory contents to disk and then enters low power mode.

Because it doesn't need to restore the saved memory, a suspended system can resume more quickly than a hibernating system. However, if the computer loses power while suspended, running programs are not properly restored.

The following code lets the program suspend or hibernate the system.

// Suspend. private void btnSuspend_Click(object sender, EventArgs e) { Application.SetSuspendState(PowerState.Suspend, false, false); } // Hibernate. private void btnHibernate_Click(object sender, EventArgs e) { Application.SetSuspendState(PowerState.Hibernate, false, false); }

For more information about the SetSuspendState method, see Application.SetSuspendState Method.

Download the example to experiment with it and to see additional details.

© 2009-2022 Rocky Mountain Computer Consulting, Inc. All rights reserved.