Click here to Skip to main content
15,884,237 members
Home / Discussions / C#
   

C#

 
GeneralRe: Acquiring a property value Pin
Blubbo26-Jul-13 1:50
Blubbo26-Jul-13 1:50 
GeneralRe: Acquiring a property value Pin
Dave Kreskowiak26-Jul-13 2:35
mveDave Kreskowiak26-Jul-13 2:35 
AnswerRe: Acquiring a property value Pin
OriginalGriff25-Jul-13 21:39
mveOriginalGriff25-Jul-13 21:39 
AnswerRe: Acquiring a property value Pin
Blubbo26-Jul-13 4:38
Blubbo26-Jul-13 4:38 
GeneralRe: Acquiring a property value Pin
PIEBALDconsult26-Jul-13 7:55
mvePIEBALDconsult26-Jul-13 7:55 
GeneralRe: Acquiring a property value Pin
Richard MacCutchan26-Jul-13 22:26
mveRichard MacCutchan26-Jul-13 22:26 
AnswerRe: Acquiring a property value Pin
coolcat22731-Jul-13 11:29
coolcat22731-Jul-13 11:29 
QuestionPower management hybernation is causing my application to hang ... Pin
turbosupramk325-Jul-13 2:50
turbosupramk325-Jul-13 2:50 
I have background threads that are doing things and based on logging when the computer goes to sleep, the threads cause the application to hang because of timing I would assume. I would like to abort the threads when the machine goes to sleep and bring them back when it wakes up, or something else if there is another way?

I tried inserting the code below yesterday, but I did not see any messageboxes below when I came in this morning and the application was hung again. This is my first time encountering power management issues, so I'm new to this override code.

Thanks for reading.


C#
protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
                case WM_POWERBROADCAST:
                    switch (m.WParam.ToInt32())
                    {
                        //value passed when system is going on standby / suspended
                        case PBT_APMQUERYSUSPEND:
                            if (reminderThread.IsAlive == true)
                            {
                                reminderThreadTerminate = true;
                                MessageBox.Show("reminderThreadTerminate set to true");
                            }
                            //List<string> arr =
                            //  Properties.Settings.Default.StandDownApps.Split(',').ToList();
                            //foreach (string item in arr)
                            //{
                            //    foreach (Process p in
                            //       System.Diagnostics.Process.GetProcessesByName(item))
                            //    {
                            //        try
                            //        {
                            //            //Exiting the applications when going into standby
                            //            p.Kill();
                            //            p.WaitForExit(3600000); // 1 min timeout
                            //        }
                            //        catch
                            //        {
                            //            // process was terminating or can't be terminated
                            //        }
                            //    }
                            //}
                            break;
                        //value passed when system is resumed after suspension.
                        case PBT_APMRESUMESUSPEND:
                            if (reminderThread.IsAlive == false)
                            {
                                reminderThread.Start();
                                MessageBox.Show("reminderThreadTerminate started");
                            }
                            else if (reminderThread.IsAlive == true)
                            {
                                reminderThreadTerminate = true;
                                Thread.Sleep(2000);
                                reminderThread.Start();
                                MessageBox.Show("reminderThreadTerminate was still running, it was killed and then restarted");
                            }
                            //arr = Properties.Settings.Default.StandUpApps.Split(',').ToList();
                            //foreach (string item in arr)
                            //{
                            //    //Starting the applications when coming up from standby
                            //    System.Diagnostics.Process.Start(item);
                            //}
                            break;

                        //value passed when system Suspend Failed
                        case (PBT_APMQUERYSUSPENDFAILED):
                        //value passed when system is suspended
                        case (PBT_APMSUSPEND):
                        //value passed when system is resumed automatically
                        case (PBT_APMRESUMEAUTOMATIC):
                        //value passed when system is resumed from critical
                        //suspension possibly due to battery failure
                        case (PBT_APMRESUMECRITICAL):
                        //value passed when system is low on battery
                        case (PBT_APMBATTERYLOW):
                        //value passed when system power status changed
                        //from battery to AC power or vice-a-versa
                        case (PBT_APMPOWERSTATUSCHANGE):
                        //value passed when OEM Event is fired. Not sure what that is??
                        case (PBT_APMOEMEVENT):
                            break;
                    }
                    break;
                default:
                    break;
            }
            base.WndProc(ref m);
        }

AnswerRe: Power management hybernation is causing my application to hang ... Pin
turbosupramk326-Jul-13 3:47
turbosupramk326-Jul-13 3:47 
Questionusing System.Diagnostics.Stopwatch in an Button_Click Event: unusual results in specific test case Pin
BillWoodruff25-Jul-13 0:55
professionalBillWoodruff25-Jul-13 0:55 
AnswerRe: using System.Diagnostics.Stopwatch in an Button_Click Event: unusual results in specific test case Pin
Dave Kreskowiak25-Jul-13 1:15
mveDave Kreskowiak25-Jul-13 1:15 
GeneralRe: using System.Diagnostics.Stopwatch in an Button_Click Event: unusual results in specific test case Pin
BillWoodruff25-Jul-13 21:48
professionalBillWoodruff25-Jul-13 21:48 
GeneralRe: using System.Diagnostics.Stopwatch in an Button_Click Event: unusual results in specific test case Pin
Dave Kreskowiak26-Jul-13 7:00
mveDave Kreskowiak26-Jul-13 7:00 
GeneralRe: using System.Diagnostics.Stopwatch in an Button_Click Event: unusual results in specific test case Pin
BillWoodruff30-Jul-13 4:57
professionalBillWoodruff30-Jul-13 4:57 
GeneralRe: using System.Diagnostics.Stopwatch in an Button_Click Event: unusual results in specific test case Pin
Dave Kreskowiak30-Jul-13 5:46
mveDave Kreskowiak30-Jul-13 5:46 
AnswerRe: using System.Diagnostics.Stopwatch in an Button_Click Event: unusual results in specific test case PinPopular
Alan N25-Jul-13 4:27
Alan N25-Jul-13 4:27 
GeneralRe: using System.Diagnostics.Stopwatch in an Button_Click Event: unusual results in specific test case Pin
BillWoodruff25-Jul-13 21:13
professionalBillWoodruff25-Jul-13 21:13 
QuestionParamerterized OleDB Query Pin
gautamn199025-Jul-13 0:21
gautamn199025-Jul-13 0:21 
AnswerRe: Paramerterized OleDB Query Pin
Dave Kreskowiak25-Jul-13 1:17
mveDave Kreskowiak25-Jul-13 1:17 
GeneralRe: Paramerterized OleDB Query Pin
gautamn199025-Jul-13 19:28
gautamn199025-Jul-13 19:28 
GeneralRe: Paramerterized OleDB Query Pin
Dave Kreskowiak26-Jul-13 2:52
mveDave Kreskowiak26-Jul-13 2:52 
GeneralRe: Paramerterized OleDB Query Pin
gautamn199028-Jul-13 19:03
gautamn199028-Jul-13 19:03 
AnswerRe: Paramerterized OleDB Query Pin
PIEBALDconsult25-Jul-13 14:19
mvePIEBALDconsult25-Jul-13 14:19 
GeneralRe: Paramerterized OleDB Query Pin
gautamn199025-Jul-13 19:45
gautamn199025-Jul-13 19:45 
GeneralRe: Paramerterized OleDB Query Pin
PIEBALDconsult26-Jul-13 7:58
mvePIEBALDconsult26-Jul-13 7:58 

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.