Click here to Skip to main content
15,918,003 members
Home / Discussions / C#
   

C#

 
GeneralRe: IEnumerator Pin
Judah Gabriel Himango14-Jan-06 12:19
sponsorJudah Gabriel Himango14-Jan-06 12:19 
GeneralRe: IEnumerator Pin
Duif15-Jan-06 3:57
Duif15-Jan-06 3:57 
GeneralRe: IEnumerator Pin
Duif15-Jan-06 4:08
Duif15-Jan-06 4:08 
AnswerRe: IEnumerator Pin
[Marc]14-Jan-06 12:07
[Marc]14-Jan-06 12:07 
QuestionListView columns not displayed Pin
Ravi Bhavnani14-Jan-06 10:14
professionalRavi Bhavnani14-Jan-06 10:14 
AnswerRe: ListView columns not displayed Pin
Joshua Quick14-Jan-06 12:46
Joshua Quick14-Jan-06 12:46 
GeneralRe: ListView columns not displayed Pin
Ravi Bhavnani14-Jan-06 13:24
professionalRavi Bhavnani14-Jan-06 13:24 
QuestionNeed help with a Windows Service Pin
Nathan R14-Jan-06 9:13
Nathan R14-Jan-06 9:13 
I am trying to write a Windows Service that monitors the system for user input (either through mouse or keyboard), and shuts the system down if it has been inactive for a certain period of time. It has to be a service, because a primary requirement is that it shuts down a PC sitting at a login window.

The service needs GUI for 1) Adjusting the service settings or monitoring the service in real-time, and 2) To provide a warning window if the machine is about to shut down (only when someone has logged in).

I created the project as a Windows Service, then wrote and debugged it using Main to get the application to run, as follows:

	public class AutoShutdown_Class : System.ServiceProcess.ServiceBase<br />
	{<br />
	<br />
		.<br />
		.<br />
		.<br />
<br />
		public static void Main ()<br />
		{<br />
			// Create a new and run a new instance of this class.<br />
			System.ServiceProcess.ServiceBase.Run(new AutoShutdown_Class());<br />
<br />
<br />
			Event_Watcher Events = new Event_Watcher();<br />
			Application.Run(new Settings());<br />
		}


The program has the following classes:
1.Auto Shutdown Service - service constructor, Main, OnStart, OnStop
2.Event Watcher - monitors the system to see if there is any user input, and keeps track of how long the system has been idle. Reads and writes settings from/to a file. Shuts the PC down if it has been idle for a certain period of time.
3.Settings - Windows Form that displays a status window, which is accessed by a user through a system tray icon. Changes the user makes to the settings are passed to the Event Watcher
4.Warning - Windows Form that displays a message when a system is about to be shutdown (only when a user is logged in).

It runs as intended during debugging when coded as above; however, when I try to move the last 2 lines of code from Main into OnStart (then compile and installutil), the service won't start as it says there is no work to be done.

It seems like I've followed the wrong approach and now need to figure out how to get back on track. From reading various message boards, it appears that I need to separate the above into an application and service. I've read some (extremely abstract) code about named pipes, but I really haven't been able to make sense of 1) What parts would go into the application and what would stay in the service, and 2) how the 2 would communicate.

Any and all suggestions are welcomed
AnswerRe: Need help with a Windows Service Pin
Nathan R16-Jan-06 9:48
Nathan R16-Jan-06 9:48 
GeneralRe: Need help with a Windows Service Pin
BlackDice2-Feb-06 11:33
BlackDice2-Feb-06 11:33 
QuestionWrite to a text file Pin
aPerfectCircle14-Jan-06 8:43
aPerfectCircle14-Jan-06 8:43 
AnswerRe: Write to a text file Pin
User 665814-Jan-06 8:59
User 665814-Jan-06 8:59 
QuestionRemoting with localizable resources Pin
machocr14-Jan-06 8:07
machocr14-Jan-06 8:07 
QuestionSystem.Security.SecurityException Pin
OMalleyW14-Jan-06 5:23
OMalleyW14-Jan-06 5:23 
QuestionRe: System.Security.SecurityException Pin
shopi3014-Jan-06 12:31
shopi3014-Jan-06 12:31 
AnswerRe: System.Security.SecurityException Pin
OMalleyW14-Jan-06 14:14
OMalleyW14-Jan-06 14:14 
QuestionHow insert controlls inide a listbox Pin
Sasuko14-Jan-06 4:23
Sasuko14-Jan-06 4:23 
AnswerRe: How insert controlls inide a listbox Pin
rabih_kai14-Jan-06 5:29
rabih_kai14-Jan-06 5:29 
Questionweb deployment set up project in .net 2005 Pin
cppdotnet14-Jan-06 1:23
cppdotnet14-Jan-06 1:23 
QuestionDrill down crystal reports in C# Pin
idreesbadshah14-Jan-06 1:03
idreesbadshah14-Jan-06 1:03 
QuestionHow can I get the contents of a given URL and edit it while displaying? Pin
sachu_vidya14-Jan-06 0:02
sachu_vidya14-Jan-06 0:02 
AnswerRe: How can I get the contents of a given URL and edit it while displaying? Pin
Mark Shehan14-Jan-06 13:50
Mark Shehan14-Jan-06 13:50 
GeneralRe: How can I get the contents of a given URL and edit it while displaying? Pin
sachu_vidya16-Jan-06 20:47
sachu_vidya16-Jan-06 20:47 
Questionhow do I implement scrolling? Pin
mihai_152913-Jan-06 21:59
mihai_152913-Jan-06 21:59 
AnswerRe: how do I implement scrolling? Pin
Robert Rohde13-Jan-06 22:20
Robert Rohde13-Jan-06 22:20 

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.