Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / December 2005

Tip: Looking for answers? Try searching our database.

Problem running a scheduled service

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Michael Groeger - 14 Dec 2005 09:10 GMT
Hi NG,

I have written a service which should start at certain time in the morning
and stop at a certain time in the evening. For this, I added the following
to the Main() method of the service:

public void Main(string[] args)
{
   // [...]
   if (args.Length == 1)
   {
       if (args[0] == "-startsvc")
       {
           ServiceController ctrl = new ServiceController("MyService",
".");
           ctrl.Start();
       }
       else if (args[0] == "-stopsvc")
       {
           ServiceController ctrl = new ServiceController("MyService",
".");
           ctrl.Stop();
       }
       // [...]
   }
   // [...]
}

I use Scheduled Tasks to run and stop the service and certain times.
However, when Windows (2000) is locked and the the service should start or
stop, the service cannot but instead throws an
System.InvalidOperationException. Can somebody help?

Regards,
Michael
Michael Groeger - 14 Dec 2005 11:09 GMT
Hi,

sorry, my fault. The service was not running as I tried to stop it.

Regards,
Michael

> Hi NG,
>
[quoted text clipped - 31 lines]
> Regards,
> Michael

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.