Solved

C# .NET Windows Service calling a console app

Posted on 2004-08-23
4
309 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: 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!

Question has a verified solution.

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

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Simple Linear Regression
Introduction to Processes

726 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