sh-beta
sh-beta

Reputation: 3969

Why does my C# program pause so often when running from the Windows 7 command line?

I've had this problem with several different C# apps. These are all utility programs I've written to make my life as a sysadmin easier. Things like migrating data between database servers.

They print their current step to the console (old versions through System.Console.WriteLine(), newer ones through log4net's ConsoleAppender), so I always run them from a command prompt. When doing so, they often seem to pause at random intervals until I hit enter a few times. I notice they're paused because a step that usually takes a second or two has been on the screen for a long time. After hitting enter, things start processing normally again for a while.

Why is this? How can I fix it?

Upvotes: 4

Views: 634

Answers (2)

macropas
macropas

Reputation: 3160

The simplest assumption - an application goes to the branch with the call Console.ReadLine(). It is not enough information to make any other assumption. Eventually, try to initiate Break-command in the debugger during the program hanging, etc.

Upvotes: 0

RobSiklos
RobSiklos

Reputation: 8849

If you select text on the command window screen using the mouse, it often pauses execution of the program that is running. You might be accidentally creating a text selection when clicking on the window with the mouse.

Upvotes: 9

Related Questions