<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Things Falling Off Aircraft (TFOA) &#187; c#</title>
	<atom:link href="http://alittlestrange.com/tfoa/tag/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://alittlestrange.com/tfoa</link>
	<description>- and other technical difficulties</description>
	<lastBuildDate>Wed, 26 May 2010 04:29:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Command Line Progress Bar C#</title>
		<link>http://alittlestrange.com/tfoa/2008/11/10/command-line-progress-bar-c/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://alittlestrange.com/tfoa/2008/11/10/command-line-progress-bar-c/#comments</comments>
		<pubDate>Mon, 10 Nov 2008 23:20:00 +0000</pubDate>
		<dc:creator>Bobby Shea</dc:creator>
				<category><![CDATA[App-Dev]]></category>
		<category><![CDATA[c#]]></category>

		<guid isPermaLink="false">http://alittlestrange.com/tfoa/2008/11/10/command-line-progress-bar-c/</guid>
		<description><![CDATA[I have written quite a few command line applications and was looking for a way to show progress in much the same way as a gui progress bar. The below code accomplishes this. Simply add this to your application and call it from within your...]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a title='Original Link: http://api.tweetmeme.com/share?url=http%3A%2F%2Falittlestrange.com%2Ftfoa%2F2008%2F11%2F10%2Fcommand-line-progress-bar-c%2F'  href="http://alittlestrange.com/tfoa/?hP_8fFek"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Falittlestrange.com%2Ftfoa%2F2008%2F11%2F10%2Fcommand-line-progress-bar-c%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>I have written quite a few command line applications and was looking for a way to show progress in much the same way as a gui progress bar. The below code accomplishes this. Simply add this to your application and call it from within your processing loop:</p>
<p><span id="more-13"></span></p>
<p> </p>
<pre name=code class=csharp>
int Total = results.Count;
int i = 1;
foreach (SearchResult result in results)
{
drawTextProgressBar(i, Total);
i++;
}

private static void drawTextProgressBar(int progress, int total)
{
//draw empty progress bar
Console.CursorLeft = 0;
Console.Write("["); //start
Console.CursorLeft = 32;
Console.Write("]"); //end
Console.CursorLeft = 1;
float onechunk = 30.0f / total;

//draw filled part
int position = 1;
for (int i = 0; i &lt; onechunk * progress; i++)
{
Console.BackgroundColor = ConsoleColor.Gray;
Console.CursorLeft = position++;
Console.Write(" ");
}

//draw unfilled part
for (int i = position; i &lt; 31; i++)
{
Console.BackgroundColor = ConsoleColor.Black;
Console.CursorLeft = position++;
Console.Write(" ");
}

//draw totals
Console.CursorLeft = 35;
Console.BackgroundColor = ConsoleColor.Black;
Console.Write(progress.ToString() + " of " + total.ToString() + " "); //blanks at the end remove any excess
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://alittlestrange.com/tfoa/2008/11/10/command-line-progress-bar-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
