473,395 Members | 1,495 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Pausing the console program before it returns

Right now my solution to this is adding Console.ReadLine 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 2656
"Marin" <ma***@gmail.comwrote in message
news:7q***************************@40tude.net...
Right now my solution to this is adding Console.ReadLine 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.comwrote:
>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.Diagnostics.Debugger.IsAttached)
{
Console.WriteLine("Press [enter] to exit");
Console.ReadLine();
}

--
Dave Sexton

"Marin" <ma***@gmail.comwrote in message
news:7q***************************@40tude.net...
Right now my solution to this is adding Console.ReadLine 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.Diagnostics.Debugger.IsAttached)
{
Console.WriteLine("Press [enter] to exit");
Console.ReadLine();
}

--
Dave Sexton

"Marin" <ma***@gmail.comwrote in message
news:7q***************************@40tude.net...
Right now my solution to this is adding Console.ReadLine 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*******@yahoo.nospammin.comwrote in message
news:B9**********************************@microsof t.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.Diagnostics.Debugger.IsAttached)
{
Console.WriteLine("Press [enter] to exit");
Console.ReadLine();
}

--
Dave Sexton

"Marin" <ma***@gmail.comwrote in message
news:7q***************************@40tude.net.. .
Right now my solution to this is adding Console.ReadLine 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
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...
4
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...
7
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...
4
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...
4
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...
25
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...
2
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...
12
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...
4
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...
0
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...

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.