• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 317
  • Last Modified:

C# .NET Windows Service calling a console app

Hello,
I have a C# console app that is called by a Windows service every minute as a process. The weird part is that when the console app is called it does part of what it's supposed to do, and then just hangs there (I can see it in Task Manager processes). When I stop the service, the console app does the rest of the work and then closes. Any ideas why it completes only when the service is stopped? the service should keep running, the console app should run and exit ...and then run again after a minute and exit...HELP!!!
0
gvmdevelopment
Asked:
gvmdevelopment
  • 2
1 Solution
 
cookreCommented:
I assume you're not getting multiple instances of the console app conflicting with one another.

<aside>
The service should check before spawning, just in case:
bool IsMyAppRunning()
{
Process[] ProcList;
ProcList=Process.GetProcessesByName("whatevertheappnameis");
if (ProcList.Length==0) return false;
return true;
}
</aside>

It sounds like there's some contention for a file - log file perhaps?

How is the app started in the service?
What does the service do after the app is started?
What is the app doing when it hangs?
Does it hang in the same spot?
0
 
Eran_RCommented:
If you redirect input/output of the console app and you do not read what the app writes, it may run out of buffers and then get stuck when trying to write to the console output.

When you stop your service that redirection pipe gets broken and the console app can continue.

This is just a wild guess, but it could be the reason...
0
 
gvmdevelopmentAuthor Commented:
Eran, you nailed it! I can't believe it was something so simple....
0
 
gvmdevelopmentAuthor Commented:
and Cookre, the reason you suggested was taken care of by disabling the timer before the app is called and then re-enabling it once it exits.... so there *probably* is no way there can be multiple instances of the app... Thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now