Solved

C# .NET Windows Service calling a console app

Posted on 2004-08-23
4
306 Views
Last Modified: 2010-04-17
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
Comment
Question by:gvmdevelopment
  • 2
4 Comments
 
LVL 22

Expert Comment

by:cookre
ID: 11872381
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
 
LVL 4

Accepted Solution

by:
Eran_R earned 500 total points
ID: 11872571
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
 
LVL 1

Author Comment

by:gvmdevelopment
ID: 11872869
Eran, you nailed it! I can't believe it was something so simple....
0
 
LVL 1

Author Comment

by:gvmdevelopment
ID: 11872901
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question