473,763 Members | 7,727 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Pausing the console program before it returns

Right now my solution to this is adding Console.ReadLin e at the end but I'm
wondering if it's possible to do it automatically?

If I chose "Start without debug" it does just that, it pauses right before
the console window closes, but "Start with debug" closes the window right
away.
Dec 2 '06 #1
5 2677
"Marin" <ma***@gmail.co mwrote in message
news:7q******** *************** ****@40tude.net ...
Right now my solution to this is adding Console.ReadLin e at the end but
I'm
wondering if it's possible to do it automatically?
Of course, if you start a console program from a console window, the console
window will remain open when the program finishes. The problem arises only
when you start the program by launching it directly (so it has to create its
own console window).

You may be able to make a shortcut to the .exe file and set the attributes
of the shortcut so that the window will remain there when the program ends.
Dec 2 '06 #2
Marin <ma***@gmail.co mwrote:
>If I chose "Start without debug" it does just that, it pauses right before
the console window closes, but "Start with debug" closes the window right
away.
My solution: put a breakpoint at the closing } of Main.

That way, when I run it in debug mode, I get to see the output.
And when I run the release program from a console prompt, I get to see
the output.

--
Lucian
Dec 2 '06 #3
Hi Marin,

I add the following code to the end of the Main method in my console
applications (sometimes):

if (System.Diagnos tics.Debugger.I sAttached)
{
Console.WriteLi ne("Press [enter] to exit");
Console.ReadLin e();
}

--
Dave Sexton

"Marin" <ma***@gmail.co mwrote in message
news:7q******** *************** ****@40tude.net ...
Right now my solution to this is adding Console.ReadLin e at the end but
I'm
wondering if it's possible to do it automatically?

If I chose "Start without debug" it does just that, it pauses right before
the console window closes, but "Start with debug" closes the window right
away.

Dec 2 '06 #4
Which, incidentally, answers somebody else's kind of nebulous question about
"How can I tell if my program is running in debug mode".
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Dave Sexton" wrote:
Hi Marin,

I add the following code to the end of the Main method in my console
applications (sometimes):

if (System.Diagnos tics.Debugger.I sAttached)
{
Console.WriteLi ne("Press [enter] to exit");
Console.ReadLin e();
}

--
Dave Sexton

"Marin" <ma***@gmail.co mwrote in message
news:7q******** *************** ****@40tude.net ...
Right now my solution to this is adding Console.ReadLin e at the end but
I'm
wondering if it's possible to do it automatically?

If I chose "Start without debug" it does just that, it pauses right before
the console window closes, but "Start with debug" closes the window right
away.


Dec 2 '06 #5
Hi Peter,

Possibly :)

--
Dave Sexton

"Peter Bromberg [C# MVP]" <pb*******@yaho o.nospammin.com wrote in message
news:B9******** *************** ***********@mic rosoft.com...
Which, incidentally, answers somebody else's kind of nebulous question
about
"How can I tell if my program is running in debug mode".
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Dave Sexton" wrote:
>Hi Marin,

I add the following code to the end of the Main method in my console
applications (sometimes):

if (System.Diagnos tics.Debugger.I sAttached)
{
Console.WriteLi ne("Press [enter] to exit");
Console.ReadLin e();
}

--
Dave Sexton

"Marin" <ma***@gmail.co mwrote in message
news:7q******* *************** *****@40tude.ne t...
Right now my solution to this is adding Console.ReadLin e at the end but
I'm
wondering if it's possible to do it automatically?

If I chose "Start without debug" it does just that, it pauses right
before
the console window closes, but "Start with debug" closes the window
right
away.



Dec 2 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
7615
by: Dr. Know | last post by:
I am working on an ASP page that writes to several databases, ranging from MDBs to x-base. One of the tasks involves using an existing highest value from the DB and incrementing it before inserting a new record. I am using Application.Lock and .Unlock together with an application variable to negotiate access to the DB routine to one session (user) at a time. This is to ensure that the ID numbers are cleanly incremented, and that no...
4
30370
by: Kerwin Cabrera | last post by:
I am writing a console application and I would like to put a "Press any key..." message once the program is done executing. Currently, when it executes it returns to the prompt. I have tried console.read and console.readline but they both require an <Enter> key to be hit. Any suggestions Thanks -KC
7
2695
by: Charles Law | last post by:
My first thought was to call WorkerThread.Suspend but the help cautions against this (for good reason) because the caller has no control over where the thread actually stops, and it might have a lock pending, for example. I want to be able to stop a thread temporarily, and then optionally resume it or stop it for good.
4
1320
by: Rob | last post by:
When issuing... System.Console.Write and WriteLine commands... the program shells out to Command prompt, displays message, and closes... there is no time to view what is shown,,, how can you keep the console up in order to view the contents ? Thanks
4
4498
by: Manfred Braun | last post by:
Hi All ! I think, there is a bug in the System.Console class related to use the STDIO streams. I am doing a very simple thing in a console-based program named CS Console.In.Peek(); and the program hungs if no parameters were provided on the commandline. If I use simple redirection like "echo "hallo" | cs.exe"
25
2315
by: Kwebway Konongo | last post by:
Hi everyone, I'm developing an application in C; basically a linked list, with a series of "events" to be popped off, separated by a command to pause reading off the next event in the list. It has been sometime since I last did C, and that was the first K&R version! Is there a command to pause an app for a period of time, as all the commands I am familiar with specify pauses for integer numbers of seconds, and what I would like is...
2
1923
by: myburt | last post by:
Hi im writing a very "simple" program in C# for a console app.. I'm supposed to make a program that asks a user how many dice to roll, rolls a six sided die that many times, and returns the total and average roll.(this is all coming out of a book "C# programming for absolute beginners") I cant figure how to get the value of the dice roll outside of the for statement please help. { class Program { static void...
12
3330
by: greg | last post by:
Hi, Can anyone help me with the following issue: How can I pause the execution of a program until a given file is created (by another process) in a specified directory? Any ideas would be highly appreciated. Thanks!
4
10513
by: Peter Nimmo | last post by:
Hi, I am writting a windows application that I want to be able to act as if it where a Console application in certain circumstances, such as error logging. Whilst I have nearly got it, it doesn't seem to write to the screen in the way I would expect. The output is:
0
9386
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10144
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9997
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9937
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9822
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3522
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2793
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.