I've written a Windows Service that periodically executes a SSIS package that moves documents from Server A
to Server B
.
The problem is that in order to do so, I need to use an infinite loop, which starts when the Service starts.
Naturally, I placed this loop into the OnStart()
method. Unfortunately, the service never signals that it has started, since it never reaches the end of this method...
Here is the relevant code:
protected override void OnStart(string[] args)
{
Application app = new Application();
Package pkg = app.LoadFromDtsServer(@"MSDB\PullDoc", "Server", null);
while (true)
{
DTSExecResult pkgResults = pkg.Execute();//Execute the package.
EventLog.WriteEntry(pkgResults.ToString());
Thread.Sleep(1000 * 60 * 5);//Sleep at least five minutes.
}
}
I would imagine this is a common problem, given that most Services should be running indefinitely.
Any ideas on how to get this service to return that it has started?
Thanks!