Solved

C# .NET Windows Service calling a console app

Posted on 2004-08-23
4
304 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
triangle challenge 4 122
countHi challenge 25 101
Program to display an alert on Windows Toolbar 2 71
how to use laptop or pad camera in vb.net windows application 2 55
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

863 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now