Tuesday, May 5, 2015

When Processing large data , my computer becomes idle and c# console application also gets halted.


which namespace this method is in , let me know.



You have to P/Invoke it.  That means you specify a DllImport attribute on a static method (in whatever namespace and class you wish) that will effectively result in calling the method directly in kernel32.dll.  The constants must be defined manually, but fortunately, PInvoke.net has specific details for this and many other methods and their associated constants.  Just cut and paste the code on that page and follow the examples.

Since you're having trouble, I'll provide an excerpt here:

[DllImport("kernel32.dll", CharSet = CharSet.Auto,SetLastError = true)]
static extern EXECUTION_STATE SetThreadExecutionState(EXECUTION_STATE esFlags);

[FlagsAttribute]
public enum EXECUTION_STATE :uint
{
     ES_AWAYMODE_REQUIRED = 0x00000040,
     ES_CONTINUOUS = 0x80000000,
     ES_DISPLAY_REQUIRED = 0x00000002,
     ES_SYSTEM_REQUIRED = 0x00000001
}


No comments:

Post a Comment