Solved

C# .NET Windows Service calling a console app

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
MaxSpan challenge 9 67
hasOne  challenge 59 90
Using YubiKey with REST API application 2 80
count8 challlenge 13 85
Purpose To explain how to place a textual stamp on a PDF document.  This is commonly referred to as an annotation, or possibly a watermark, but a watermark is generally different in that it is somewhat translucent.  Watermark’s may be text or graph…
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

705 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

21 Experts available now in Live!

Get 1:1 Help Now