0

I have an application build on Visual Studio 2013 with C# and Windows Forms.

This application runs on system tray and every 15 minutes (using a System.Windows.Forms.Timer component) visits a REST website, gets JSON data from it and displays them on the application.

The application is in Beta (i have it installed in a few clients for testing) and i was informed that very rarely, after computer recovers from sleep mode it will throw an exception (you can continue using it pressing the continue in the popup window as i was informed).

I have never seen this error in any of my development rigs (Windows 7 64bit, Windows 8.1 and then updated to Windows 10). The two clients that informed me about this exception were running Windows 7 32bit and 64bit.

I have seen this but what should i do when Mode is changed? Should i stop the Timer and then restart it when the Mode changes back to PowerModes.Resume?

Community
  • 1
  • 1
gemantzu
  • 723
  • 1
  • 7
  • 12
  • What is the exception? – Mihai Caracostea Aug 29 '15 at 13:07
  • Unfortunately i don't know, the clients did not write this down (they are not technical at all). – gemantzu Aug 29 '15 at 13:47
  • 2
    I would recommend adding Logging to the application such that when exceptions (like this one) are thrown, they are written to the event log or an application log file. Then you would know where the exception was being thrown from. It is likely that the first attempt to access the REST interface may occur while the network adapter is still coming back to life from sleep mode. It is also likely that the next iteration of the timer would work as expected (users hit continue and app continues to work). – John Bartels Aug 29 '15 at 13:50
  • Then there's not much we can do but speculate. I am voting to close this for now. – Mihai Caracostea Aug 29 '15 at 15:13

1 Answers1

0

As per the answer to this SO Post, Timer checks if any event has missed and fires accordingly. So the exception might be related to getting data from the REST website.

Maybe the exception occurs because your network card is turned off by the OS to save power. Try getting some details of the exception.

Community
  • 1
  • 1
Abhishek
  • 2,925
  • 4
  • 34
  • 59