tags:

views:

64

answers:

4

I've written a very basic HTTP-based server program that runs in the background on my computer to allow me to automate various tasks from my Android (via HTTP requests in Tasker). This all works fine (barring this problem), except that after more than about 30 minutes of inactivity, the application ends up in a sort of sleep mode, and takes a good minute or so to wake up when it receives an HTTP request or when I try to restore the window and interact with the UI.

I'm using System.Net.HttpListener to implement the server (using asynchronous calls to BeginListen). How should I go about keeping it on its toes?

+1  A: 

Maybe you could do another thread and check if your HttpListerner instance IsListening periodically?

stuudent
This seems to have done the trick! Thanks :)
Will Vousden
+2  A: 

Is it possible that your process memory is being swapped out to disk? Perhaps write a little monitor task that just pings it every 5 minutes? Note that this could also be useful for making sure it's still running - it could email you if it's down, for example :)

Jon Skeet
+2  A: 

Hello

What is your OS (Windows XP / Seven / Server 2008 ...) and distribution ? (Home / Pro / SBS...) ?

Try to give hight priority to your process (like realtime).

You can also try to perform some task with your process every 10 minutes...

G. Qyy
+1  A: 

Looks like the problem description is missing mentioning of the actual problem itself. On windows applications do not go into sleep mode. Inactive apps might be swapped, but it should not take very long time when it gets a request. In .Net 2 I have noticed similar behavior due to garbage collection of the Listener Object itself or associated objects due to long inactivity. Try to keep a static reference of the listener object.This might help.

Bhuvan