473,659 Members | 2,664 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

pause in console apps

When you run a console app in VS6 it says "Press any key too continue..."
how can i do that in VS.NET2003?

thanks
Nov 16 '05 #1
5 44945
Console.WriteLi ne("Press any key too continue...");
Console.ReadLin e();
// continue...

--
William Stacey, MVP

"Aaron" <ku*****@yahoo. com> wrote in message
news:#n******** ******@TK2MSFTN GP10.phx.gbl...
When you run a console app in VS6 it says "Press any key too continue..."
how can i do that in VS.NET2003?

thanks


Nov 16 '05 #2
William Stacey [MVP] wrote:
Console.WriteLi ne("Press any key too continue...");
Console.ReadLin e();
// continue...
"Aaron" <ku*****@yahoo. com> wrote in message
news:#n******** ******@TK2MSFTN GP10.phx.gbl...
When you run a console app in VS6 it says "Press any key too
continue..." how can i do that in VS.NET2003?

thanks


Note that Console.ReadLin e() only returns on a newline (the enter key), not
any key.
- Pete
Nov 16 '05 #3
Have a variable incremented in KeyDown event.
Print out the message "Press any key..."
AforeMentionedV ariable = 0;
while (AforeMentioned Variable == 0);
--
Alex Moskalyuk
_______________ ______________
http://www.techinterviews.com

"Aaron" <ku*****@yahoo. com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
When you run a console app in VS6 it says "Press any key too continue..."
how can i do that in VS.NET2003?

thanks

Nov 16 '05 #4
Alex Moskalyuk <us****@moskaly uk.com> wrote:
Have a variable incremented in KeyDown event.
Which KeyDown event is that, in a console app?
Print out the message "Press any key..."
AforeMentionedV ariable = 0;
while (AforeMentioned Variable == 0);


That's not guaranteed to *ever* finish, unless the variable is volatile
- and even if the variable were volatile, you'd still be taking up 100%
CPU until someone pressed a key. Tight loops like that should (almost)
never be used for that kind of thing - it's what Monitor.Wait/Pulse was
designed for.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #5
You're right, my bad. I was just working with textboxes that looked like
consoles and were called consoles (black backgrounds, white characters),
being in fact textboxes. Missed the fact that he asked for Win32 console
app.
--
Alex Moskalyuk
_______________ ______________
http://www.techinterviews.com

"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
Alex Moskalyuk <us****@moskaly uk.com> wrote:
Have a variable incremented in KeyDown event.


Which KeyDown event is that, in a console app?
Print out the message "Press any key..."
AforeMentionedV ariable = 0;
while (AforeMentioned Variable == 0);


That's not guaranteed to *ever* finish, unless the variable is volatile
- and even if the variable were volatile, you'd still be taking up 100%
CPU until someone pressed a key. Tight loops like that should (almost)
never be used for that kind of thing - it's what Monitor.Wait/Pulse was
designed for.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 16 '05 #6

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

Similar topics

2
357
by: Aaron | last post by:
When you run a console app in VS6 it says "Press any key too continue..." how can i do that in VS.NET2003? thanks
5
4132
by: Brian.Steele | last post by:
Greetings everyone. See http://www.spiceisle.com/cgi-bin/slideshow/slideshow.cgi?dir=brian/personal/2005/uk_trip/images&type=jpg The "Pause" button works in IE, but not in Firefox. Any ideas why? If you have any other ideas on how the javascript can be improved, please let me know.
8
36442
by: Wim | last post by:
My GUI application starts a process (a console program) when the user hits Play. I would like to add an option to pause that process. The code I've added to detect if the user hit pause/unpause seems to work. But I have no clue how to pause/suspend the process. As far as I can see the Process class doesn't offer anything for this. So it's probably the thread the process is running on that should be suspended or put to sleep. But just...
1
547
by: Dan Williams | last post by:
Does anyone know if its possible to pause the console output if my console app tries to write data past the current command prompt buffer? In other words, behave much like the 'more' command, in that it stops outputting and waits for the user to hit space to display the next pages worth, or enter for the next line? Thanks in advance for any suggestions. Dan.
3
1456
by: GG | last post by:
I have a console app that when it is run and I press a key then it freezes till a press another key gain. Is there a way to avoid it that is the keystrokes do not pause the app? Thanks *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
6
6620
by: Mark Broadbent | last post by:
Firstly I am not after a programatic solution (e.g. Console.ReadLine() or a Loop construct). I am trying to find an option in the IDE to pause on exit. For instance with the SharpDevelop IDE there is a checkbox to do this, but I cant find it in VS2003 -but I will be surprised if it doesnt have one. .....So where is it?? Thanks,
5
11228
by: Barry Mossman | last post by:
Hi, can I detect whether my class is running within the context of a Console application, vs say a WinForm's application ? also does anyone know whether the compiler or runtime is smart enough to avoid the overhead of writing to the console if it is not visible, eg I am running inside a WinForm application. thanks
6
45645
by: kai | last post by:
Hi, When I use Console.WriteLine("Hello") in my code, it displays DOS screen so fast, how do I pause the Console screen? Thanks Kai
0
1401
by: Arik | last post by:
Hi, I would like to disable the 'Pause/Break' key in a console application. Normally, pressing the 'Pause' key halts the application's execution and may lead to undesirable processing gaps in my system. I tried to 'listen' for input key presses using Console.ReadKey(), but it turns out that it doesn't recognize the 'Pause' key (among other keys).
6
4048
by: Peted | last post by:
Hi wondering what is the best way to do this Need a user to click a button, that sends 3 or 4 string based commands via a TCP/ip socket link I can connect to the ip device no problems, am using indy sockets, and can send information ok
0
8850
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
8746
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...
0
8626
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
7355
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5649
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
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4334
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2749
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1737
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.