Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / January 2006

Tip: Looking for answers? Try searching our database.

Prevent console close

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
barbutz - 17 Jan 2006 08:24 GMT
Hi,

I have a console application.
I need to prevent the user from closing the application by closing the
console window. Is there a way to do that? Maybe to catch the console close
event and cancel it?
Please if there is a way tell me how to do that.

Thanks.
Lau Lei Cheong - 17 Jan 2006 09:00 GMT
Add a call to the following calls at the end.
Console.Write("Press enter to continue...");
Console.ReadLine() ;

"barbutz" <barbutz@discussions.microsoft.com> ¼¶¼g©ó¶l¥ó·s»D:F4B06509-26DD-45C8-BDB9-57837786DEC0@microsoft.com...
> Hi,
>
[quoted text clipped - 6 lines]
>
> Thanks.
Lau Lei Cheong - 17 Jan 2006 09:11 GMT
Oops... I misread your question.

The fact is, your console application has no control on when the shell
(hence the window contains it) terminates. So you can't stop that.

Your question sounds analogic to "Whether I can keep my program running if
someone shutdowns Windows?"

"Lau Lei Cheong" <leu_lc@yehoo.com.hk> ¼¶¼g©ó¶l¥ó·s»D:eFOYHS0GGHA.3896@TK2MSFTNGP15.phx.gbl...
> Add a call to the following calls at the end.
> Console.Write("Press enter to continue...");
[quoted text clipped - 11 lines]
>>
>> Thanks.
Jeroen Vandezande - 17 Jan 2006 09:44 GMT
> Hi,
>
[quoted text clipped - 4 lines]
> event and cancel it?
> Please if there is a way tell me how to do that.

Hi,

Like the other poster said: you don't have control over the console
window...
If it is that important you should concider making the console app into a
service application.
unless you do a lot of user IO it should not be a problem to do so.

Best Regards,

Jeroen Vandezande

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.