Click here to Skip to main content
15,898,222 members
Home / Discussions / C#
   

C#

 
AnswerRe: how do I change a regex Pin
Tomáš Podešva2-Feb-15 17:14
professionalTomáš Podešva2-Feb-15 17:14 
AnswerRe: how do I change a regex Pin
OriginalGriff2-Feb-15 21:18
mveOriginalGriff2-Feb-15 21:18 
GeneralRe: how do I change a regex Pin
Member 113543863-Feb-15 14:03
Member 113543863-Feb-15 14:03 
GeneralRe: how do I change a regex Pin
OriginalGriff3-Feb-15 23:28
mveOriginalGriff3-Feb-15 23:28 
Questionwindows 8 hybrid shutdown notification Pin
morglorf2-Feb-15 11:33
morglorf2-Feb-15 11:33 
AnswerRe: windows 8 hybrid shutdown notification Pin
Richard Andrew x642-Feb-15 11:53
professionalRichard Andrew x642-Feb-15 11:53 
GeneralRe: windows 8 hybrid shutdown notification Pin
morglorf2-Feb-15 12:17
morglorf2-Feb-15 12:17 
GeneralRe: windows 8 hybrid shutdown notification Pin
morglorf3-Feb-15 5:54
morglorf3-Feb-15 5:54 
Well, I tried using the SystemEvents.PowerModeChanged event, which is the managed analog to what you suggested. I received the Suspend and Resume events just fine but nothing for a power down (even a hybrid one). The mode enumeration is not terribly detailed. It offers Resume (aka wake), Suspend (aka sleep), and some other battery-related modes which are not pertinent to my problem. The return values from the PInvoke you suggested look much the same, so I did not try that.

Also note that I did my experimenting from a Windows Forms program. To do this from a service, MS says it's required to have a message pump in the service, which involves a hidden form and sounds kind of kludgey.

Instead I have this work around: I didn't mention that I also have a user tray app running that monitors the service. On a sleep the system doesn't exit the tray app. On a hybrid shutdown the system does. So in the form close event of tray app I use the CloseReason to find out if it's a non-user exit. If it is I send a custom message to the service to do it's shutdown processing. Sending a custom message is pretty easy:

ServiceController sc = new ServiceController("MyService");
sc.ExecuteCommand(MYSERVICE_QUASI_SHUTDOWN);

...then in the service, the custom command is handled in the OnCustomCommand event handler. MYSERVICE_QUASI_SHUTDOWN is some constant int you pick.
I've read that there's some valid range for it, so as not to step on the future, however I forget what that is just now.
QuestionHelp with Array search. Pin
Member 114193361-Feb-15 18:18
Member 114193361-Feb-15 18:18 
AnswerRe: Help with Array search. Pin
Richard Andrew x641-Feb-15 18:34
professionalRichard Andrew x641-Feb-15 18:34 
GeneralRe: Help with Array search. Pin
Member 114193361-Feb-15 19:28
Member 114193361-Feb-15 19:28 
AnswerRe: Help with Array search. Pin
BillWoodruff1-Feb-15 21:16
professionalBillWoodruff1-Feb-15 21:16 
AnswerRe: Help with Array search. Pin
Richard Deeming2-Feb-15 2:53
mveRichard Deeming2-Feb-15 2:53 
AnswerRe: Help with Array search. Pin
ramazan aktolu3-Feb-15 7:36
ramazan aktolu3-Feb-15 7:36 
QuestionTrouble binding with TCP to same local endpoint Pin
Mc_Topaz1-Feb-15 4:07
Mc_Topaz1-Feb-15 4:07 
AnswerRe: Trouble binding with TCP to same local endpoint Pin
Richard MacCutchan1-Feb-15 5:22
mveRichard MacCutchan1-Feb-15 5:22 
GeneralRe: Trouble binding with TCP to same local endpoint Pin
Mc_Topaz1-Feb-15 5:27
Mc_Topaz1-Feb-15 5:27 
GeneralRe: Trouble binding with TCP to same local endpoint Pin
Richard MacCutchan1-Feb-15 6:05
mveRichard MacCutchan1-Feb-15 6:05 
GeneralRe: Trouble binding with TCP to same local endpoint Pin
Mc_Topaz1-Feb-15 6:43
Mc_Topaz1-Feb-15 6:43 
GeneralRe: Trouble binding with TCP to same local endpoint Pin
OriginalGriff1-Feb-15 7:43
mveOriginalGriff1-Feb-15 7:43 
GeneralRe: Trouble binding with TCP to same local endpoint Pin
OriginalGriff1-Feb-15 5:38
mveOriginalGriff1-Feb-15 5:38 
GeneralRe: Trouble binding with TCP to same local endpoint Pin
Richard MacCutchan1-Feb-15 6:05
mveRichard MacCutchan1-Feb-15 6:05 
NewsRe: Trouble binding with TCP to same local endpoint Pin
Mc_Topaz1-Feb-15 6:39
Mc_Topaz1-Feb-15 6:39 
AnswerRe: Trouble binding with TCP to same local endpoint Pin
Pete O'Hanlon2-Feb-15 6:31
mvePete O'Hanlon2-Feb-15 6:31 
GeneralRe: Trouble binding with TCP to same local endpoint Pin
Mc_Topaz2-Feb-15 19:57
Mc_Topaz2-Feb-15 19:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.