Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > .NET 1.0 and Visual Studio.NET > VS.NET 2002/2003
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
VS.NET 2002/2003 Discussions about the Visual Studio.NET programming environment, the 2002 (1.0) and 2003 (1.1). ** Please don't post code questions here ** For issues specific to a particular language in .NET, please see the other forum categories.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VS.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 26th, 2004, 01:37 AM
Registered User
 
Join Date: May 2004
Location: Perth, WA, Australia.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to FarCry Send a message via AIM to FarCry Send a message via MSN to FarCry
Default Ending a console application

Hi,

I have a console application that runs about 4 threads - when a thread dies it should automaticaly restart within a few seconds, however this does not always occur. So what i've been trying to do is make it so the application will quit when a thread creates an exception. If i let the exception go the application just sits there doing nothing at all, if i catch the exception and end the thread i have no way to end the application.

What i need is a command to end the console application. This is not a GUI/Windows application so there is no way to access the "Application" class the exit the program. Because this application runs on both windows and linux (with the same problems on both) i cant use forms ;)

Essentialy what im asking is: How do i make the damn thing die?

Mark Harris
FireDaemon
Web Application Developer
Reply With Quote
  #2 (permalink)  
Old May 26th, 2004, 09:19 AM
Friend of Wrox
Points: 3,489, Level: 24
Points: 3,489, Level: 24 Points: 3,489, Level: 24 Points: 3,489, Level: 24
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Central, NJ, USA.
Posts: 1,102
Thanks: 0
Thanked 2 Times in 2 Posts
Default

why focus on killing the proccess instead of fixing the problem with the restarts?


Hal Levy
Web Developer, PDI Inc.

NOT a Wiley/Wrox Employee
Reply With Quote
  #3 (permalink)  
Old May 26th, 2004, 09:28 AM
Registered User
 
Join Date: May 2004
Location: Perth, WA, Australia.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to FarCry Send a message via AIM to FarCry Send a message via MSN to FarCry
Default

It doesnt really matter, the kill way will fix any others which have cropped up. Its a fairly complex irc bot (1500 lines of code heh - not including the irc library). As you probably know, irc is prone to little errors. So i figure its easier to put the bot into FireDaemon - when the bot goes down it will be restarted in 10 seconds anyway.

Is there a command you know of for CLI apps?

Mark Harris
FireDaemon
Web Application Developer
Reply With Quote
  #4 (permalink)  
Old May 26th, 2004, 09:34 AM
Friend of Wrox
Points: 3,489, Level: 24
Points: 3,489, Level: 24 Points: 3,489, Level: 24 Points: 3,489, Level: 24
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Central, NJ, USA.
Posts: 1,102
Thanks: 0
Thanked 2 Times in 2 Posts
Default

no- I don't do console apps.

My first thought is to kill the proccess from the command line (a kill -9 PID) in unix.. There's something similar on NT>


Hal Levy
Web Developer, PDI Inc.

NOT a Wiley/Wrox Employee
Reply With Quote
  #5 (permalink)  
Old May 26th, 2004, 10:40 AM
Registered User
 
Join Date: May 2004
Location: Perth, WA, Australia.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to FarCry Send a message via AIM to FarCry Send a message via MSN to FarCry
Default

the problem is there is no way to tell if the process has died or not.

Mark Harris
FireDaemon
Web Application Developer
Reply With Quote
  #6 (permalink)  
Old May 26th, 2004, 10:47 AM
Friend of Wrox
Points: 3,489, Level: 24
Points: 3,489, Level: 24 Points: 3,489, Level: 24 Points: 3,489, Level: 24
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Central, NJ, USA.
Posts: 1,102
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Didn't you say you can catch the exception? When you catch it- you run the kill process on it.

Hal Levy
Web Developer, PDI Inc.

NOT a Wiley/Wrox Employee
Reply With Quote
  #7 (permalink)  
Old May 26th, 2004, 10:50 AM
Registered User
 
Join Date: May 2004
Location: Perth, WA, Australia.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to FarCry Send a message via AIM to FarCry Send a message via MSN to FarCry
Default

i catch them all - how would i run a kill process on the application without doing it manualy?

Mark Harris
FireDaemon
Web Application Developer
Reply With Quote
  #8 (permalink)  
Old May 26th, 2004, 10:59 AM
Friend of Wrox
Points: 3,489, Level: 24
Points: 3,489, Level: 24 Points: 3,489, Level: 24 Points: 3,489, Level: 24
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Central, NJ, USA.
Posts: 1,102
Thanks: 0
Thanked 2 Times in 2 Posts
Default

When you catch the exception you can run a shell kill

Hal Levy
Web Developer, PDI Inc.

NOT a Wiley/Wrox Employee
Reply With Quote
  #9 (permalink)  
Old May 26th, 2004, 11:06 AM
Registered User
 
Join Date: May 2004
Location: Perth, WA, Australia.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to FarCry Send a message via AIM to FarCry Send a message via MSN to FarCry
Default

i dont mean to sound like an utter idiot - but how can this be done in an automatic fashion - i dont want an application watching for console output - or have to have me sit there waiting as i need to sleep some time ;)

Mark Harris
FireDaemon
Web Application Developer
Reply With Quote
  #10 (permalink)  
Old May 26th, 2004, 11:17 AM
Friend of Wrox
Points: 3,489, Level: 24
Points: 3,489, Level: 24 Points: 3,489, Level: 24 Points: 3,489, Level: 24
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Central, NJ, USA.
Posts: 1,102
Thanks: 0
Thanked 2 Times in 2 Posts
Default

You said you can catch the exception programatically. In the routine where you catch the exception you can execute a shell command that kills the parent thread for the console application- that's my guess and what I would try.


Hal Levy
Web Developer, PDI Inc.

NOT a Wiley/Wrox Employee
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Console application but no Console gamotter C# 2 August 22nd, 2007 11:41 PM
Console Application digby_dog VB.NET 2002/2003 Basics 2 April 29th, 2005 10:52 AM
Console application and web application nsrujan ASP.NET 1.0 and 1.1 Basics 1 April 16th, 2005 10:35 PM
Application still runing even after Ending it PakXoxer Pro VB 6 4 March 9th, 2005 02:10 AM
SendMail from a Console Application r_ganesh76 General .NET 3 March 1st, 2005 11:25 AM



All times are GMT -4. The time now is 09:45 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.