Recommended

  • Silverlight.FX
    Silverlight.FX is a light-weight application framework for building RichInternet Applications with Silverlight 2.
  • Building Modular Silverlight Applications
  • Prism -  10 Things to Know
  • Securing Silverlight Application and WCF Service using ASP.Net Authentication Techniques
  • Model– View – ViewModel in Silverlight
Skip Navigation LinksHome / News / View News

Free Tool and Source Code to Temporarily Prevent a Machine From Going to Sleep

+ Add to SilverlightShow Favorites
0 comments   /   posted by Silverlight Show on Oct 02, 2009
(0 votes)
Tags: Applications , WPF

David Anson posted about a WPF application called Insomnia which calls the SetThreadExecutionState API to disable sleep mode for as long as it's running.

Insomnia basically boils down to a single function call - but to a function that's a Win32 API and is not part of the .NET Framework. This is where a very powerful feature saves the day: Platform Invoke. For those who aren't familiar with it, P/Invoke (as it's called) lets a managed application call into the APIs exposed by a native DLL. All it takes is a dash of the DllImport attribute and a little bit of translation from the Win32 types to their managed counterparts. The MSDN documentation goes into lots of detail here, and I encourage interested parties to go there.

Share


Comments

Comments RSS RSS
No comments

Add Comment

 
 

   
  
  
   
Please add 7 and 6 and type the answer here: