<?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>CyrusBuilt dot Net</title>
	<atom:link href="http://cyrusbuilt.net/wordpress/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://cyrusbuilt.net/wordpress</link>
	<description>A place for geeks  ;-)</description>
	<lastBuildDate>Thu, 05 Apr 2012 18:36:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>PLC Makers Still Got Their Heads in the Sand</title>
		<link>http://cyrusbuilt.net/wordpress/?p=355</link>
		<comments>http://cyrusbuilt.net/wordpress/?p=355#comments</comments>
		<pubDate>Thu, 05 Apr 2012 18:32:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Computer Hardware]]></category>
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://cyrusbuilt.net/wordpress/?p=355</guid>
		<description><![CDATA[Share So ummmm&#8230;. this is pretty awesome: Researchers Release New Exploits to Hijack Critical Infrastructure And here&#8217;s my favorite part: In January, the team disclosed several vulnerabilities they found in the Modicon Quantum system, including the lack of authentication and the presence of about 12 backdoor accounts that were hard coded into the system and that [...]]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><div style="float: right; width: 42px; padding-right: 90px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		reddit_url = "http://cyrusbuilt.net/wordpress/?p=355";
		reddit_title = "PLC Makers Still Got Their Heads in the Sand";
		//-->
		</script>
		<script type="text/javascript" src="http://www.reddit.com/button.js?t=1"></script></div><div style="float: right; width: 70px; margin: 0 0 0 10px;">
<script type="text/javascript">
function fbs_click() {
u=location.href;
t=document.title;
window.open("http://www.facebook.com/sharer.php?u="+encodeURIComponent(u)+"&t="+encodeURIComponent(t),"sharer","toolbar=0,status=0,width=626,height=436");
return false;
}
</script>
<style type="text/css">
html .fb_share_button {display: -moz-inline-block; display:inline-block; padding:1px 20px 0 5px; height:15px; border:1px solid #d8dfea; background:url(http://b.static.ak.fbcdn.net/images/share/facebook_share_icon.gif?8:26981) no-repeat top right;}
html .fb_share_button:hover {color:#fff; border-color:#295582; background:#3b5998 url(http://b.static.ak.fbcdn.net/images/share/facebook_share_icon.gif?8:26981) no-repeat top right; text-decoration:none;}
</style>
<a href="http://www.facebook.com/share.php?u=http://cyrusbuilt.net/wordpress/?p=355" class="fb_share_button" onclick="return fbs_click()" target="_blank" style="text-decoration:none;">Share</a></div><div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		digg_url = "http://cyrusbuilt.net/wordpress/?p=355";
		digg_bgcolor = "#FFFFFF";
		digg_skin = "";
		digg_window = "";
		digg_title = "PLC Makers Still Got Their Heads in the Sand";
		digg_media = "news";
		digg_topic = "";
		digg_bodytext = "";
		//-->
		</script>
		<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script></div><!--S-ButtonZ 1.1.5 End--><p>So ummmm&#8230;. this is pretty awesome:</p>
<p><a href="http://www.wired.com/threatlevel/2012/04/exploit-for-quantum-plc/?utm_source=feedburner&amp;utm_medium=feed&amp;utm_campaign=Feed%3A+wired%2Findex+%28Wired%3A+Index+3+%28Top+Stories+2%29%29" target="_blank">Researchers Release New Exploits to Hijack Critical Infrastructure</a></p>
<p>And here&#8217;s my favorite part:</p>
<blockquote><p>In January, the team <a href="http://www.wired.com/threatlevel/2012/01/scada-exploits/">disclosed several vulnerabilities they found in the Modicon Quantum system</a>, including the lack of authentication and the presence of about 12 backdoor accounts that were hard coded into the system and that have read/write capability. The system also has a web server password that is stored in plaintext and is retrievable via an FTP backdoor.</p></blockquote>
<p>&nbsp;</p>
<p>Wow.  Seriously?</p>
<div style="clear:both;">&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://cyrusbuilt.net/wordpress/?feed=rss2&#038;p=355</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>One More Reason Why I Refuse to Develop for the iFruits.</title>
		<link>http://cyrusbuilt.net/wordpress/?p=349</link>
		<comments>http://cyrusbuilt.net/wordpress/?p=349#comments</comments>
		<pubDate>Thu, 15 Mar 2012 22:38:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://cyrusbuilt.net/wordpress/?p=349</guid>
		<description><![CDATA[Share http://www.osnews.com/story/25717/Depending_on_an_application_store_for_your_income As the author suggests, this is what happens when you depend on a company to survive that *does not* depend on you. The long and short of it is this: This guy develops for the iFruits and thus depends on the Mac App Store to release his wares and get paid for them. [...]]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><div style="float: right; width: 42px; padding-right: 90px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		reddit_url = "http://cyrusbuilt.net/wordpress/?p=349";
		reddit_title = "One More Reason Why I Refuse to Develop for the iFruits.";
		//-->
		</script>
		<script type="text/javascript" src="http://www.reddit.com/button.js?t=1"></script></div><div style="float: right; width: 70px; margin: 0 0 0 10px;">
<script type="text/javascript">
function fbs_click() {
u=location.href;
t=document.title;
window.open("http://www.facebook.com/sharer.php?u="+encodeURIComponent(u)+"&t="+encodeURIComponent(t),"sharer","toolbar=0,status=0,width=626,height=436");
return false;
}
</script>
<style type="text/css">
html .fb_share_button {display: -moz-inline-block; display:inline-block; padding:1px 20px 0 5px; height:15px; border:1px solid #d8dfea; background:url(http://b.static.ak.fbcdn.net/images/share/facebook_share_icon.gif?8:26981) no-repeat top right;}
html .fb_share_button:hover {color:#fff; border-color:#295582; background:#3b5998 url(http://b.static.ak.fbcdn.net/images/share/facebook_share_icon.gif?8:26981) no-repeat top right; text-decoration:none;}
</style>
<a href="http://www.facebook.com/share.php?u=http://cyrusbuilt.net/wordpress/?p=349" class="fb_share_button" onclick="return fbs_click()" target="_blank" style="text-decoration:none;">Share</a></div><div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		digg_url = "http://cyrusbuilt.net/wordpress/?p=349";
		digg_bgcolor = "#FFFFFF";
		digg_skin = "";
		digg_window = "";
		digg_title = "One More Reason Why I Refuse to Develop for the iFruits.";
		digg_media = "news";
		digg_topic = "";
		digg_bodytext = "";
		//-->
		</script>
		<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script></div><!--S-ButtonZ 1.1.5 End--><p><a href="http://www.osnews.com/story/25717/Depending_on_an_application_store_for_your_income" target="_blank">http://www.osnews.com/story/25717/Depending_on_an_application_store_for_your_income</a></p>
<p>As the author suggests, this is what happens when you depend on a company to survive that *does not* depend on you. The long and short of it is this: This guy develops for the iFruits and thus depends on the Mac App Store to release his wares and get paid for them. Apple makes a goof, and the guy&#8217;s Developer account gets revoked, and thus all his apps removed from the store. So now he&#8217;s not making any money. And of course, Apple (in typical fashion), offers little or no explanation as to why that happened or if and when they will restore his account.</p>
<p>The usual excuse I keep hearing is: &#8220;Dude there is a ton of apps and a ton of members, and its a nightmare to handle all that.&#8221; 2 things: 1) they are a TECH company. If their technology doesn&#8217;t scale well, then they need to develop a solution to fix that shit. I&#8217;m absolutely positive they employ a great many talented engineers and developers that can tackle this. 2) If anything, throw more people at it. Not enough man-power to manage it? OK, great, hire some more! It isn&#8217;t like Apple isn&#8217;t a giant in the tech industry and making money hand-over-fist.</p>
<p>/ End of Rant /</p>
<div style="clear:both;">&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://cyrusbuilt.net/wordpress/?feed=rss2&#038;p=349</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NASA Goes Open Source</title>
		<link>http://cyrusbuilt.net/wordpress/?p=347</link>
		<comments>http://cyrusbuilt.net/wordpress/?p=347#comments</comments>
		<pubDate>Sat, 07 Jan 2012 03:54:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[NASA]]></category>

		<guid isPermaLink="false">http://cyrusbuilt.net/wordpress/?p=347</guid>
		<description><![CDATA[Share This made me giggle like a school girl. Finally, my tax dollars got put to good use. NASA just released several projects open source. I&#8217;ve already been digging through their code and am absorbing it like a sponge. Very cool stuff: http://code.nasa.gov/ &#160;]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><div style="float: right; width: 42px; padding-right: 90px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		reddit_url = "http://cyrusbuilt.net/wordpress/?p=347";
		reddit_title = "NASA Goes Open Source";
		//-->
		</script>
		<script type="text/javascript" src="http://www.reddit.com/button.js?t=1"></script></div><div style="float: right; width: 70px; margin: 0 0 0 10px;">
<script type="text/javascript">
function fbs_click() {
u=location.href;
t=document.title;
window.open("http://www.facebook.com/sharer.php?u="+encodeURIComponent(u)+"&t="+encodeURIComponent(t),"sharer","toolbar=0,status=0,width=626,height=436");
return false;
}
</script>
<style type="text/css">
html .fb_share_button {display: -moz-inline-block; display:inline-block; padding:1px 20px 0 5px; height:15px; border:1px solid #d8dfea; background:url(http://b.static.ak.fbcdn.net/images/share/facebook_share_icon.gif?8:26981) no-repeat top right;}
html .fb_share_button:hover {color:#fff; border-color:#295582; background:#3b5998 url(http://b.static.ak.fbcdn.net/images/share/facebook_share_icon.gif?8:26981) no-repeat top right; text-decoration:none;}
</style>
<a href="http://www.facebook.com/share.php?u=http://cyrusbuilt.net/wordpress/?p=347" class="fb_share_button" onclick="return fbs_click()" target="_blank" style="text-decoration:none;">Share</a></div><div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		digg_url = "http://cyrusbuilt.net/wordpress/?p=347";
		digg_bgcolor = "#FFFFFF";
		digg_skin = "";
		digg_window = "";
		digg_title = "NASA Goes Open Source";
		digg_media = "news";
		digg_topic = "";
		digg_bodytext = "";
		//-->
		</script>
		<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script></div><!--S-ButtonZ 1.1.5 End--><p>This made me giggle like a school girl. Finally, my tax dollars got put to good use. NASA just released several projects open source. I&#8217;ve already been digging through their code and am absorbing it like a sponge. Very cool stuff: <a href="http://code.nasa.gov/" target="_blank">http://code.nasa.gov/</a></p>
<div style="clear:both;">&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://cyrusbuilt.net/wordpress/?feed=rss2&#038;p=347</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CyrusBuilt File Utilities library v1.0.2.1 for AutoItV3 released</title>
		<link>http://cyrusbuilt.net/wordpress/?p=345</link>
		<comments>http://cyrusbuilt.net/wordpress/?p=345#comments</comments>
		<pubDate>Tue, 20 Sep 2011 20:22:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AutoIt]]></category>
		<category><![CDATA[CyrusBuilt Software]]></category>
		<category><![CDATA[Operating Systems]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://cyrusbuilt.net/wordpress/?p=345</guid>
		<description><![CDATA[Share As always, you can download it from the usual spot. &#160;]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><div style="float: right; width: 42px; padding-right: 90px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		reddit_url = "http://cyrusbuilt.net/wordpress/?p=345";
		reddit_title = "CyrusBuilt File Utilities library v1.0.2.1 for AutoItV3 released";
		//-->
		</script>
		<script type="text/javascript" src="http://www.reddit.com/button.js?t=1"></script></div><div style="float: right; width: 70px; margin: 0 0 0 10px;">
<script type="text/javascript">
function fbs_click() {
u=location.href;
t=document.title;
window.open("http://www.facebook.com/sharer.php?u="+encodeURIComponent(u)+"&t="+encodeURIComponent(t),"sharer","toolbar=0,status=0,width=626,height=436");
return false;
}
</script>
<style type="text/css">
html .fb_share_button {display: -moz-inline-block; display:inline-block; padding:1px 20px 0 5px; height:15px; border:1px solid #d8dfea; background:url(http://b.static.ak.fbcdn.net/images/share/facebook_share_icon.gif?8:26981) no-repeat top right;}
html .fb_share_button:hover {color:#fff; border-color:#295582; background:#3b5998 url(http://b.static.ak.fbcdn.net/images/share/facebook_share_icon.gif?8:26981) no-repeat top right; text-decoration:none;}
</style>
<a href="http://www.facebook.com/share.php?u=http://cyrusbuilt.net/wordpress/?p=345" class="fb_share_button" onclick="return fbs_click()" target="_blank" style="text-decoration:none;">Share</a></div><div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		digg_url = "http://cyrusbuilt.net/wordpress/?p=345";
		digg_bgcolor = "#FFFFFF";
		digg_skin = "";
		digg_window = "";
		digg_title = "CyrusBuilt File Utilities library v1.0.2.1 for AutoItV3 released";
		digg_media = "news";
		digg_topic = "";
		digg_bodytext = "";
		//-->
		</script>
		<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script></div><!--S-ButtonZ 1.1.5 End--><p>As always, you can download it from the <a href="http://cyrusbuilt.net/wordpress/?page_id=55" target="_self">usual spot</a>.</p>
<div style="clear:both;">&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://cyrusbuilt.net/wordpress/?feed=rss2&#038;p=345</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Transactional (Buffered) File Logging in C#</title>
		<link>http://cyrusbuilt.net/wordpress/?p=327</link>
		<comments>http://cyrusbuilt.net/wordpress/?p=327#comments</comments>
		<pubDate>Fri, 09 Sep 2011 03:04:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://cyrusbuilt.net/wordpress/?p=327</guid>
		<description><![CDATA[Share One of the biggest hurdles I&#8217;ve had to overcome in applications that do file logging is the the ability to write to a log file from one process or thread and be *read* from another process or thread in near real time. Its all about timing.  If the timing is a little off, a [...]]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><div style="float: right; width: 42px; padding-right: 90px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		reddit_url = "http://cyrusbuilt.net/wordpress/?p=327";
		reddit_title = "Transactional (Buffered) File Logging in C#";
		//-->
		</script>
		<script type="text/javascript" src="http://www.reddit.com/button.js?t=1"></script></div><div style="float: right; width: 70px; margin: 0 0 0 10px;">
<script type="text/javascript">
function fbs_click() {
u=location.href;
t=document.title;
window.open("http://www.facebook.com/sharer.php?u="+encodeURIComponent(u)+"&t="+encodeURIComponent(t),"sharer","toolbar=0,status=0,width=626,height=436");
return false;
}
</script>
<style type="text/css">
html .fb_share_button {display: -moz-inline-block; display:inline-block; padding:1px 20px 0 5px; height:15px; border:1px solid #d8dfea; background:url(http://b.static.ak.fbcdn.net/images/share/facebook_share_icon.gif?8:26981) no-repeat top right;}
html .fb_share_button:hover {color:#fff; border-color:#295582; background:#3b5998 url(http://b.static.ak.fbcdn.net/images/share/facebook_share_icon.gif?8:26981) no-repeat top right; text-decoration:none;}
</style>
<a href="http://www.facebook.com/share.php?u=http://cyrusbuilt.net/wordpress/?p=327" class="fb_share_button" onclick="return fbs_click()" target="_blank" style="text-decoration:none;">Share</a></div><div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		digg_url = "http://cyrusbuilt.net/wordpress/?p=327";
		digg_bgcolor = "#FFFFFF";
		digg_skin = "";
		digg_window = "";
		digg_title = "Transactional (Buffered) File Logging in C#";
		digg_media = "news";
		digg_topic = "";
		digg_bodytext = "";
		//-->
		</script>
		<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script></div><!--S-ButtonZ 1.1.5 End--><p>One of the biggest hurdles I&#8217;ve had to overcome in applications that do file logging is the the ability to write to a log file from one process or thread and be *read* from another process or thread in <em>near real time.</em> Its all about timing.  If the timing is a little off, a failure is going to occur due to file locking problems.  Even when both processes or threads are accessing the file with as little locking as possible.</p>
<p>Sooner or later you&#8217;re going to get an exception (usually <a href="http://msdn.microsoft.com/en-us/library/system.io.ioexception.aspx" target="_blank">System.IO.IOexception</a>).  I solved this using a transactional method that incorporates the use of a ReaderWriterLock and a specialized type of collection called a Queue.  A ReaderWriterLock (<a href="http://msdn.microsoft.com/en-us/library/system.threading.readerwriterlock.aspx" target="_blank">System.Threading.ReaderWriterLock</a>) is a special type of lock that supports single writers and multiple readers.  What this means is:  You can acquire a lock for single thread doing writes, but still allow multiple concurrent threads to read.</p>
<p>A Queue (<a href="http://msdn.microsoft.com/en-us/library/7977ey2c.aspx" target="_blank">System.Collections.Generic.Queue&lt;T&gt;</a>) is a type-safe collection of First In, Last Out objects.  Yes, this is essentially a FIFO buffer.  For our purposes, we&#8217;ll use this to queue a message string which we will retrieve when we are ready to <em>actually</em> write the message to a file.  The idea is to use a class that starts a queue processor, of sorts, that will take messages out of the queue in a first come, first serve manner and write each message to the file immediately.  What this means is the write buffers created by <a href="http://msdn.microsoft.com/en-us/library/system.io.streamwriter.aspx" target="_blank">System.IO.StreamWriter</a> and <a href="http://msdn.microsoft.com/en-us/library/system.io.filestream.aspx" target="_blank">System.IO.FileStream</a> will be immediately flushed to disk instead of hanging out in the buffer until a later time.  The only buffering we will be using is the Queue itself.  In doing so, we help to ensure that messages are stored before some condition such as a catastrophic error or unexpected shutdown occurs.  So with the queue running on a separate thread, we can submit messages to the queue and then the queue processor will process them as they come in.  In this way, we avoid collisions because only one thread is writing to the file at a time.</p>
<p>This scheme would allow for a thread in a Windows Service or daemon (for example) to write to the file while allowing another program using a sentinel (such as a <a href="http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx" target="_blank">FileSystemWatcher</a>) to monitor changes to the file and then load the file changes into a viewer of sorts.  You could have multiple viewers reading the file while the service is writing to it.  This is particularly handy if you have some kind of monitoring or management application or maybe even an active log viewer monitoring the file being used on multiple computers across a network keeping an eye on that log.</p>
<p>Now because the queue processor is going to run on its own thread but will be given data by <em>another</em> thread, the best way to handle errors in the processor thread is to raise errors in the form of an event.  So when our queue processor encounters a corrupted state or a fatal error, we will catch the exceptions and then pass the exception object via an event that fires.  Then in the application that implements this logger can handle the events and react accordingly.  The logger also has a flag to indicate whether or not it is initialized.</p>
<p>The processor will do the following:</p>
<p>1.)  Acquire a ReaderWriterLock.<br />
2.)  Open the log file for read/write access.<br />
3.)  Acquire a thread lock.<br />
4.)  Dequeue the  message.<br />
5.)  Release the thread lock.<br />
6.)  Write the message to file and flush buffers.<br />
7.)  Release ReaderWriterLock<br />
8.)  Repeat for next message in queue.</p>
<p>This essentially makes up a <em>transaction</em>.  You submit the message to queue using a method call, then a subroutine running on another thread (message processor) processes all the messages currently in the queue and starts over.  I&#8217;m not going to go into all the details of a how ReaderWriterLock or Queue works here&#8230;.. you can read the MSDN articles that I linked above.  I&#8217;m going to demonstrate my implementation of it.  Lets start with the processor routine (some code omitted for brevity):</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">// The namespaces we need to import:</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Collections.Generic</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.IO</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Security</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Threading</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #008080; font-style: italic;">//Here's some variables that we'll need</span>
<span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">String</span> _logFilePath <span style="color: #008000;">=</span> <span style="color: #6666cc; font-weight: bold;">String</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Empty</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> Boolean _initialized <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> Boolean _enableTimestamp <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> Thread _writerThread <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> Int32 _writes <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> Int32 _writerTimeouts <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> ReaderWriterLock _rwl <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> ReaderWriterLock<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> Queue _msgQueue <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Queue<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> Mutex _logMutex <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Mutex<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #0600FF; font-weight: bold;">readonly</span> <span style="color: #6666cc; font-weight: bold;">Object</span> _writeLock <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> <span style="color: #6666cc; font-weight: bold;">Object</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #008080; font-style: italic;">// We raise this event if an error occurs.</span>
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #0600FF; font-weight: bold;">event</span> LoggerEventHandler Failed<span style="color: #008000;">;</span>
&nbsp;
<span style="color: #008080; font-style: italic;">// ...and here's the queue processor method.</span>
<span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> LogLoop<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
   FileInfo logFile <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> FileInfo<span style="color: #008000;">&#40;</span>_logFilePath<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
   <span style="color: #008080; font-style: italic;">// .... code to create log file if it does not exist goes here.</span>
&nbsp;
   <span style="color: #008080; font-style: italic;">// The outer loop.  We continue until we are no longer initialized.</span>
   Boolean succeeded <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span>
   <span style="color: #6666cc; font-weight: bold;">String</span> message <span style="color: #008000;">=</span> <span style="color: #6666cc; font-weight: bold;">String</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Empty</span><span style="color: #008000;">;</span>
   <span style="color: #0600FF; font-weight: bold;">while</span> <span style="color: #008000;">&#40;</span>_initialized<span style="color: #008000;">&#41;</span>
   <span style="color: #008000;">&#123;</span>
      <span style="color: #0600FF; font-weight: bold;">try</span>
      <span style="color: #008000;">&#123;</span>
         <span style="color: #008080; font-style: italic;">// Acquire the lock (timeout in 100ms)</span>
         _rwl<span style="color: #008000;">.</span><span style="color: #0000FF;">AcquireReaderWriterLock</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">100</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
         <span style="color: #0600FF; font-weight: bold;">try</span>
         <span style="color: #008000;">&#123;</span>
             <span style="color: #008080; font-style: italic;">// Process the messages in the queue until empty.</span>
            <span style="color: #0600FF; font-weight: bold;">while</span><span style="color: #008000;">&#40;</span>_msgQueue<span style="color: #008000;">.</span><span style="color: #0000FF;">Count</span> <span style="color: #008000;">&gt;</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
               <span style="color: #008080; font-style: italic;">// Create a FileStream in append mode. Append mode can only be used with FileAccess.Write access.</span>
               <span style="color: #008080; font-style: italic;">// We use FileShare.ReadWrite so other processes or threads can read from it even if we are currently</span>
               <span style="color: #008080; font-style: italic;">// writing to it.</span>
               <span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008000;">&#40;</span>FileStream saveStream <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> FileStream<span style="color: #008000;">&#40;</span>logFile<span style="color: #008000;">.</span><span style="color: #0000FF;">FullName</span>, FileMode<span style="color: #008000;">.</span><span style="color: #0000FF;">Append</span>, FileAccess<span style="color: #008000;">.</span><span style="color: #0000FF;">Write</span>, FileShare<span style="color: #008000;">.</span><span style="color: #0000FF;">ReadWrite</span><span style="color: #008000;">&#41;</span>
               <span style="color: #008000;">&#123;</span>
                  <span style="color: #008080; font-style: italic;">// Make sure we can write to the stream.</span>
                  <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>saveStream<span style="color: #008000;">.</span><span style="color: #0000FF;">CanWrite</span><span style="color: #008000;">&#41;</span>
                  <span style="color: #008000;">&#123;</span>
                     <span style="color: #008080; font-style: italic;">// Create the actual writer, dequeue the message, then write</span>
                      <span style="color: #008080; font-style: italic;">// it to the file immediately.</span>
                     <span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008000;">&#40;</span>StreamWriter writer <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> StreamWriter<span style="color: #008000;">&#40;</span>saveStream<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
                     <span style="color: #008000;">&#123;</span>
                        <span style="color: #008080; font-style: italic;">// Automatically flush the buffer when done.</span>
                        writer<span style="color: #008000;">.</span><span style="color: #0000FF;">AutoFlush</span> <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span>
                        <span style="color: #008080; font-style: italic;">// Clear the message string of any previous contents</span>
                        message <span style="color: #008000;">=</span> <span style="color: #6666cc; font-weight: bold;">String</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Empy</span><span style="color: #008000;">;</span>
&nbsp;
                        <span style="color: #008080; font-style: italic;">// Acquire the thread lock.</span>
                        <span style="color: #0600FF; font-weight: bold;">lock</span> <span style="color: #008000;">&#40;</span>_writeLock<span style="color: #008000;">&#41;</span>
                        <span style="color: #008000;">&#123;</span>
                           <span style="color: #0600FF; font-weight: bold;">try</span>
                           <span style="color: #008000;">&#123;</span>
                              <span style="color: #008080; font-style: italic;">// Double-check both inner and outter loop conditions to make sure</span>
                              <span style="color: #008080; font-style: italic;">// they haven't changed since the last time we checked, then</span>
                              <span style="color: #008080; font-style: italic;">// dequeue the next message.</span>
                              <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span>_initialized<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&amp;&amp;</span> <span style="color: #008000;">&#40;</span>_msgQueue<span style="color: #008000;">.</span><span style="color: #0000FF;">Count</span> <span style="color: #008000;">&gt;</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
                              <span style="color: #008000;">&#123;</span>
                                 message <span style="color: #008000;">=</span> _msgQueue<span style="color: #008000;">.</span><span style="color: #0000FF;">Dequeue</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                              <span style="color: #008000;">&#125;</span>
                           <span style="color: #008000;">&#125;</span>
                           <span style="color: #0600FF; font-weight: bold;">catch</span> <span style="color: #008000;">&#40;</span>InvalidOperationException<span style="color: #008000;">&#41;</span>
                           <span style="color: #008000;">&#123;</span>
                              <span style="color: #008080; font-style: italic;">// The queue has been emptied since we last checked _msgQueue.Count.</span>
                              <span style="color: #008080; font-style: italic;">// This is a rare but possible condition. This could, for example, happen if</span>
                              <span style="color: #008080; font-style: italic;">// Stop() was called since we last checked the _initialized flag (outter loop),</span>
                              <span style="color: #008080; font-style: italic;">// since the Stop() method clears the message queue. Since we double-check the</span>
                              <span style="color: #008080; font-style: italic;">// loop conditions right before dequeue, this should almost never happen.</span>
                           <span style="color: #008000;">&#125;</span>
                        <span style="color: #008000;">&#125;</span>
&nbsp;
                        <span style="color: #008080; font-style: italic;">// If the message is not null or empty, write it to disk.</span>
                        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">!</span><span style="color: #6666cc; font-weight: bold;">String</span><span style="color: #008000;">.</span><span style="color: #0000FF;">IsNullOrEmpty</span><span style="color: #008000;">&#40;</span>message<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
                        <span style="color: #008000;">&#123;</span>
                           writer<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span>message<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                           saveStream<span style="color: #008000;">.</span><span style="color: #0000FF;">Flush</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                           succeeded <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span>
                        <span style="color: #008000;">&#125;</span>
                     <span style="color: #008000;">&#125;</span>
                  <span style="color: #008000;">&#125;</span>
               <span style="color: #008000;">&#125;</span>
&nbsp;
               <span style="color: #008080; font-style: italic;">// Getting here, we had a successful write operation.</span>
               <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>succeeded<span style="color: #008000;">&#41;</span>
               <span style="color: #008000;">&#123;</span>
                  Interlocked<span style="color: #008000;">.</span><span style="color: #0000FF;">Increment</span><span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">ref</span> _writes<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
               <span style="color: #008000;">&#125;</span>
            <span style="color: #008000;">&#125;</span>
            Thread<span style="color: #008000;">.</span><span style="color: #0000FF;">Sleep</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">20</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
         <span style="color: #008000;">&#125;</span>
         <span style="color: #0600FF; font-weight: bold;">catch</span> <span style="color: #008000;">&#40;</span>Exception ex<span style="color: #008000;">&#41;</span>
         <span style="color: #008000;">&#123;</span>
            <span style="color: #008080; font-style: italic;">// We actually want catch as many possible exceptions, but we'll use 'Exception' as an example.</span>
            Failed<span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">null</span>, <span style="color: #008000;">new</span> LoggerEventArgs<span style="color: #008000;">&#40;</span>ex<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
         <span style="color: #008000;">&#125;</span>
         <span style="color: #0600FF; font-weight: bold;">finally</span>
         <span style="color: #008000;">&#123;</span>
            <span style="color: #008080; font-style: italic;">// Release the writer lock.</span>
            _rwl<span style="color: #008000;">.</span><span style="color: #0000FF;">ReleaseWriterLock</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
         <span style="color: #008000;">&#125;</span>
      <span style="color: #008000;">&#125;</span>
      <span style="color: #0600FF; font-weight: bold;">catch</span> <span style="color: #008000;">&#40;</span>ApplicationException<span style="color: #008000;">&#41;</span>
      <span style="color: #008000;">&#123;</span>
         <span style="color: #008080; font-style: italic;">// The lock request timed out.</span>
         Interlocked<span style="color: #008000;">.</span><span style="color: #0000FF;">Increment</span><span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">ref</span> _writerTimeouts<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
      <span style="color: #008000;">&#125;</span>
   <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>As you can see, we created our queue to hold the messages with the statement:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> Queue _msgQueue <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Queue<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></div></div>

<p>Now since the queue processor runs in its own thread, we&#8217;ll need a method for initializing it before we can actually submit any messages to it.  The initializer&#8217;s primary goal will be to perform any necessary checks prior to lift off, and will then create the thread and start it. Like so:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> Start<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
   <span style="color: #008080; font-style: italic;">// If we've already been initialized once before, then</span>
   <span style="color: #008080; font-style: italic;">// we do nothing here. This also eliminates the need to</span>
   <span style="color: #008080; font-style: italic;">// catch a ThreadStateException when calling the Thread's</span>
   <span style="color: #008080; font-style: italic;">// Start() method because the _initialized flag should</span>
   <span style="color: #008080; font-style: italic;">// only get altered by the Start() and Stop() methods</span>
   <span style="color: #008080; font-style: italic;">// of this class. If _intialized is false, then the</span>
   <span style="color: #008080; font-style: italic;">// the state of IsAlive on the thread should also be</span>
   <span style="color: #008080; font-style: italic;">// false and/or the Thread object should be null.</span>
   <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>_initialized<span style="color: #008000;">&#41;</span>
   <span style="color: #008000;">&#123;</span>
      <span style="color: #0600FF; font-weight: bold;">return</span><span style="color: #008000;">;</span>
   <span style="color: #008000;">&#125;</span>
&nbsp;
   <span style="color: #008080; font-style: italic;">// Create the logger thread and start it.</span>
   _writerThread <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Thread<span style="color: #008000;">&#40;</span><span style="color: #008000;">new</span> ThreadStart<span style="color: #008000;">&#40;</span>LogLoop<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
   _writerThread<span style="color: #008000;">.</span><span style="color: #0000FF;">IsBackground</span> <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span>
   _writerThread<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;msgLogger&quot;</span><span style="color: #008000;">;</span>
   <span style="color: #0600FF; font-weight: bold;">try</span>
   <span style="color: #008000;">&#123;</span>
      _writerThread<span style="color: #008000;">.</span><span style="color: #0000FF;">Start</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
      _initialized <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span>
   <span style="color: #008000;">&#125;</span>
   <span style="color: #0600FF; font-weight: bold;">catch</span> <span style="color: #008000;">&#40;</span>OutOfMemoryException<span style="color: #008000;">&#41;</span>
   <span style="color: #008000;">&#123;</span>
      <span style="color: #008080; font-style: italic;">// We could not allocate memory for the new thread.</span>
      <span style="color: #008080; font-style: italic;">// Just re-throw the exception, preserving the stacktrace.</span>
      <span style="color: #0600FF; font-weight: bold;">throw</span><span style="color: #008000;">;</span>
   <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>Since we have a start method, we will also need a stop method.  The stop method should empty the message queue and then abort the thread we create in the start method:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> Stop<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
   <span style="color: #008080; font-style: italic;">// Do nothing if we are not currently initialized.</span>
   <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">!</span>_initialized<span style="color: #008000;">&#41;</span>
   <span style="color: #008000;">&#123;</span>
      <span style="color: #0600FF; font-weight: bold;">return</span><span style="color: #008000;">;</span>
   <span style="color: #008000;">&#125;</span>
&nbsp;
   <span style="color: #008080; font-style: italic;">// Try to stop gracefully first.  We use a mutex to help</span>
   <span style="color: #008080; font-style: italic;">// ensure that we can alter the state flag and empty the</span>
   <span style="color: #008080; font-style: italic;">// queue.  In doing so, the queue processor should abort</span>
   <span style="color: #008080; font-style: italic;">// quietly on its own.</span>
&nbsp;
   <span style="color: #008080; font-style: italic;">// Note: The handler for the 'Failed' event should call this</span>
   <span style="color: #008080; font-style: italic;">// this method so that it does not continue on in a</span>
   <span style="color: #008080; font-style: italic;">// corrupted state.</span>
   _logMutex<span style="color: #008000;">.</span><span style="color: #0000FF;">WaitOne</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
   _initialized <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span>
   Thread<span style="color: #008000;">.</span><span style="color: #0000FF;">Sleep</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">100</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
   _msgQueue<span style="color: #008000;">.</span><span style="color: #0000FF;">Clear</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
   _logMutex<span style="color: #008000;">.</span><span style="color: #0000FF;">ReleaseMutex</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
   <span style="color: #008080; font-style: italic;">// If we're still initialized, then force the thread to abort.</span>
   <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>_initialized<span style="color: #008000;">&#41;</span>
   <span style="color: #008000;">&#123;</span>
      <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>_writerThread <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span>
      <span style="color: #008000;">&#123;</span>
         <span style="color: #0600FF; font-weight: bold;">try</span>
         <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>_writerThread<span style="color: #008000;">.</span><span style="color: #0000FF;">IsAlive</span><span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                _writerThread<span style="color: #008000;">.</span><span style="color: #0000FF;">Abort</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #008000;">&#125;</span>
         <span style="color: #008000;">&#125;</span>
         <span style="color: #0600FF; font-weight: bold;">catch</span> <span style="color: #008000;">&#40;</span>ThreadAbortException<span style="color: #008000;">&#41;</span>
         <span style="color: #008000;">&#123;</span>
            <span style="color: #008080; font-style: italic;">// By virtue of calling the Thread.Abort() method,</span>
            <span style="color: #008080; font-style: italic;">// a ThreadAbortException will occur.  Since we</span>
            <span style="color: #008080; font-style: italic;">// expect this to happen and do not intend to</span>
            <span style="color: #008080; font-style: italic;">// reset the thread, we just swallow this and</span>
            <span style="color: #008080; font-style: italic;">// and move on.</span>
         <span style="color: #008000;">&#125;</span>
         finallly
         <span style="color: #008000;">&#123;</span>
            <span style="color: #008080; font-style: italic;">// Get to the choppa!</span>
            _writerThread <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">;</span>
         <span style="color: #008000;">&#125;</span>
      <span style="color: #008000;">&#125;</span>
   <span style="color: #008000;">&#125;</span>
&nbsp;
   <span style="color: #008080; font-style: italic;">// If we were still initialized before, then we aren't now.</span>
   _initialized <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>Now that we have all that in place, we&#8217;ll need a method for getting messages into the queue so that they can be processed.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> WriteEntry<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">String</span> message<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
   <span style="color: #008080; font-style: italic;">// Stop right there! If we haven't been initialized yet, then we are</span>
   <span style="color: #008080; font-style: italic;">// in a bad state to be trying to write to the log.</span>
   <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">!</span>_initialized<span style="color: #008000;">&#41;</span>
   <span style="color: #008000;">&#123;</span>
      <span style="color: #0600FF; font-weight: bold;">throw</span> <span style="color: #008000;">new</span> InvalidOperationException<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Logger not initialized. You must start the logger before attempting to write.&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
   <span style="color: #008000;">&#125;</span>
&nbsp;
   <span style="color: #008080; font-style: italic;">// .... code for validating log file path here.</span>
&nbsp;
   <span style="color: #008080; font-style: italic;">// Convert null strings to empty strings.</span>
   <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>message <span style="color: #008000;">==</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span>
   <span style="color: #008000;">&#123;</span>
      message <span style="color: #008000;">=</span> <span style="color: #6666cc; font-weight: bold;">String</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Empty</span><span style="color: #008000;">;</span>
   <span style="color: #008000;">&#125;</span>
&nbsp;
   <span style="color: #008080; font-style: italic;">// If timestamping is enabled, the we prepend the</span>
  <span style="color: #008080; font-style: italic;">// message with a YMDHMS timestamp.</span>
  <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>_enableTimestamp<span style="color: #008000;">&#41;</span>
  <span style="color: #008000;">&#123;</span>
      message <span style="color: #008000;">=</span> <span style="color: #6666cc; font-weight: bold;">String</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Format</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;[{0}] - {1}&quot;</span>, DateTime<span style="color: #008000;">.</span><span style="color: #0000FF;">Now</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;yyyy:MM:dd:hh:mm:ss&quot;</span><span style="color: #008000;">&#41;</span>, message<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
   <span style="color: #008000;">&#125;</span>
&nbsp;
   <span style="color: #008080; font-style: italic;">// Queue the message for writing.</span>
   <span style="color: #008080; font-style: italic;">// We ensure the commit occurs by locking the thread until</span>
   <span style="color: #008080; font-style: italic;">// we are done.</span>
   <span style="color: #0600FF; font-weight: bold;">lock</span><span style="color: #008000;">&#40;</span>_writeLock<span style="color: #008000;">&#41;</span>
   <span style="color: #008000;">&#123;</span>
      _msgQueue<span style="color: #008000;">.</span><span style="color: #0000FF;">Enqueue</span><span style="color: #008000;">&#40;</span>message<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
   <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>That&#8217;s it!  So to use this thing, you call the Start() method first, then call the WriteEntry() method and when you&#8217;re done logging or if the Failed event fires, you call Stop().  You&#8217;ll obviously want to put the above code into your own static class (it is very important that this class be <strong>static</strong>) and include some public accessors for reading the _initialized flag and setting/getting the _enableTimestamp and _logFilePath values.  You probably noticed that we passed a custom event arguments object to the Failed event.  The LoggerEventArgs class is just used to pass the exception and/or message containing the details of the failure.  The following is the code for the LoggerEventArgs class:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> LoggerEventArgs <span style="color: #008000;">:</span> EventArgs
<span style="color: #008000;">&#123;</span>
   <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">String</span> _message <span style="color: #008000;">=</span> <span style="color: #6666cc; font-weight: bold;">String</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Empty</span><span style="color: #008000;">;</span>
   <span style="color: #0600FF; font-weight: bold;">private</span> Exception _exception <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">;</span>
&nbsp;
   <span style="color: #008080; font-style: italic;">// Constructors.</span>
   <span style="color: #0600FF; font-weight: bold;">public</span> LoggerEventArgs<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
      <span style="color: #008000;">:</span> <span style="color: #0600FF; font-weight: bold;">base</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
   <span style="color: #008000;">&#123;</span>
   <span style="color: #008000;">&#125;</span>
&nbsp;
   <span style="color: #0600FF; font-weight: bold;">public</span> LoggerEventArgs<span style="color: #008000;">&#40;</span>Exception ex<span style="color: #008000;">&#41;</span>
      <span style="color: #008000;">:</span> <span style="color: #0600FF; font-weight: bold;">base</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
   <span style="color: #008000;">&#123;</span>
      <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span>_exception <span style="color: #008000;">=</span> ex<span style="color: #008000;">;</span>
   <span style="color: #008000;">&#125;</span>
&nbsp;
   <span style="color: #0600FF; font-weight: bold;">public</span> LoggerEventArgs<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">String</span> message, Exception ex<span style="color: #008000;">&#41;</span>
      <span style="color: #008000;">:</span> <span style="color: #0600FF; font-weight: bold;">base</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
   <span style="color: #008000;">&#123;</span>
      <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span>_message <span style="color: #008000;">=</span> message<span style="color: #008000;">;</span>
      <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span>_exception <span style="color: #008000;">=</span> ex<span style="color: #008000;">;</span>
   <span style="color: #008000;">&#125;</span>
&nbsp;
   <span style="color: #008080; font-style: italic;">// Properties.</span>
   <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">String</span> Message
   <span style="color: #008000;">&#123;</span>
      <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span>_message<span style="color: #008000;">;</span>
   <span style="color: #008000;">&#125;</span>
&nbsp;
   <span style="color: #0600FF; font-weight: bold;">public</span> Exception EventException
   <span style="color: #008000;">&#123;</span>
      <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span>_exception<span style="color: #008000;">;</span>
   <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>We can&#8217;t fire the event without the delegate to marshal it to the handler, so here is the necessary delegate:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">delegate</span> <span style="color: #6666cc; font-weight: bold;">void</span> LoggerEventHandler<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">Object</span> sender, LoggerEventArgs e<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></div></div>

<p>Sweet, right?  &#8221;But Cyrus, how do we actually use this thing?&#8221;  Well, assuming you named your class something like &#8220;MessageLogger&#8221;, then you would do the following:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #6666cc; font-weight: bold;">void</span> Main<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">String</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> args<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
   MessageLogger<span style="color: #008000;">.</span><span style="color: #0000FF;">EnableTimeStamp</span> <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span>
   MessageLogger<span style="color: #008000;">.</span><span style="color: #0000FF;">LogFilePath</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;c:<span style="color: #008080; font-weight: bold;">\t</span>est.log&quot;</span><span style="color: #008000;">;</span>
   MessageLogger<span style="color: #008000;">.</span><span style="color: #0000FF;">Failed</span> <span style="color: #008000;">+=</span> <span style="color: #008000;">new</span> LoggerEventHandler<span style="color: #008000;">&#40;</span>MessageLogger_Failed<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
   MessageLogger<span style="color: #008000;">.</span><span style="color: #0000FF;">Start</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
   MessageLogger<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteEntry</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Hello World!&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
   MessageLogger<span style="color: #008000;">.</span><span style="color: #0000FF;">Stop</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #6666cc; font-weight: bold;">void</span> MessageLogger_Failed<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">Object</span> sender, LoggerEventArgs e<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
   Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Oh no!  The logger crashed!&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
   Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">String</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Format</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Error message: {0}&quot;</span>, e<span style="color: #008000;">.</span><span style="color: #0000FF;">EventException</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Message</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
   MessageLogger<span style="color: #008000;">.</span><span style="color: #0000FF;">Stop</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>Tada!  Good stuff.  I am sure this can be improved, but it works great for every application I&#8217;ve implemented it in so far.  It has good performance and has been quite reliable.  Even if something bad happens I can restart the logger (I use a timer for this) by calling Stop() and then Start() again.  There is a good possibility that the condition that caused the failure in the first place can be caught in the next call to Start(), assuming you&#8217;ve put all the necessary checking in there.  Happy code-slingin&#8217;!</p>
<div style="clear:both;">&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://cyrusbuilt.net/wordpress/?feed=rss2&#038;p=327</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adrift in a Sea of Spammers</title>
		<link>http://cyrusbuilt.net/wordpress/?p=323</link>
		<comments>http://cyrusbuilt.net/wordpress/?p=323#comments</comments>
		<pubDate>Thu, 02 Jun 2011 22:07:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CyrusBuilt News]]></category>
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://cyrusbuilt.net/wordpress/?p=323</guid>
		<description><![CDATA[Share Yep&#8230;. been a while.  I&#8217;ve been working on some pretty crazy projects lately, most of which I&#8217;m not allowed to talk about (signed the &#8216;ole NDA), but needless to say pretty neat. Anywho&#8230; Thought I&#8217;d get on here and have a look-see only to find out that the forums have been totally drowned in [...]]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><div style="float: right; width: 42px; padding-right: 90px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		reddit_url = "http://cyrusbuilt.net/wordpress/?p=323";
		reddit_title = "Adrift in a Sea of Spammers";
		//-->
		</script>
		<script type="text/javascript" src="http://www.reddit.com/button.js?t=1"></script></div><div style="float: right; width: 70px; margin: 0 0 0 10px;">
<script type="text/javascript">
function fbs_click() {
u=location.href;
t=document.title;
window.open("http://www.facebook.com/sharer.php?u="+encodeURIComponent(u)+"&t="+encodeURIComponent(t),"sharer","toolbar=0,status=0,width=626,height=436");
return false;
}
</script>
<style type="text/css">
html .fb_share_button {display: -moz-inline-block; display:inline-block; padding:1px 20px 0 5px; height:15px; border:1px solid #d8dfea; background:url(http://b.static.ak.fbcdn.net/images/share/facebook_share_icon.gif?8:26981) no-repeat top right;}
html .fb_share_button:hover {color:#fff; border-color:#295582; background:#3b5998 url(http://b.static.ak.fbcdn.net/images/share/facebook_share_icon.gif?8:26981) no-repeat top right; text-decoration:none;}
</style>
<a href="http://www.facebook.com/share.php?u=http://cyrusbuilt.net/wordpress/?p=323" class="fb_share_button" onclick="return fbs_click()" target="_blank" style="text-decoration:none;">Share</a></div><div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		digg_url = "http://cyrusbuilt.net/wordpress/?p=323";
		digg_bgcolor = "#FFFFFF";
		digg_skin = "";
		digg_window = "";
		digg_title = "Adrift in a Sea of Spammers";
		digg_media = "news";
		digg_topic = "";
		digg_bodytext = "";
		//-->
		</script>
		<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script></div><!--S-ButtonZ 1.1.5 End--><p>Yep&#8230;. been a while.  I&#8217;ve been working on some pretty crazy projects lately, most of which I&#8217;m not allowed to talk about (signed the &#8216;ole NDA), but needless to say pretty neat.</p>
<p>Anywho&#8230; Thought I&#8217;d get on here and have a look-see only to find out that the forums have been totally drowned in spam.  Good times.  Looks like there are only a handful of legitimate posts too.  So basically no-one is legitimately using it.</p>
<p>At all.</p>
<p>*sigh* So I set out to ban and then delete all the user accounts responsible for the spam and then I realized, why bother?  Of course I realized this *after* I went through all that trouble.  So there will be some changes to the &#8216;ole CyrusBuilt coming soon.  More than likely the forums will disappear entirely.  I&#8217;ll also be installing some upgrades while I&#8217;m at it.</p>
<div style="clear:both;">&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://cyrusbuilt.net/wordpress/?feed=rss2&#038;p=323</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Letter on Behalf of the I.T./Tech Support Professionals Around the World</title>
		<link>http://cyrusbuilt.net/wordpress/?p=320</link>
		<comments>http://cyrusbuilt.net/wordpress/?p=320#comments</comments>
		<pubDate>Tue, 08 Mar 2011 23:32:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://cyrusbuilt.net/wordpress/?p=320</guid>
		<description><![CDATA[Share This is an absolute MUST READ for everyone&#8230; not just geeks/I.T. professionals/computer technicians.  What?  Don&#8217;t just sit there reading this&#8230; go read THAT. My hats off to you, Steve Cassidy.  You&#8217;ve done a wonderful thing by writing that article, but I fear that while all of us in field fully understand and agree with [...]]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><div style="float: right; width: 42px; padding-right: 90px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		reddit_url = "http://cyrusbuilt.net/wordpress/?p=320";
		reddit_title = "A Letter on Behalf of the I.T./Tech Support Professionals Around the World";
		//-->
		</script>
		<script type="text/javascript" src="http://www.reddit.com/button.js?t=1"></script></div><div style="float: right; width: 70px; margin: 0 0 0 10px;">
<script type="text/javascript">
function fbs_click() {
u=location.href;
t=document.title;
window.open("http://www.facebook.com/sharer.php?u="+encodeURIComponent(u)+"&t="+encodeURIComponent(t),"sharer","toolbar=0,status=0,width=626,height=436");
return false;
}
</script>
<style type="text/css">
html .fb_share_button {display: -moz-inline-block; display:inline-block; padding:1px 20px 0 5px; height:15px; border:1px solid #d8dfea; background:url(http://b.static.ak.fbcdn.net/images/share/facebook_share_icon.gif?8:26981) no-repeat top right;}
html .fb_share_button:hover {color:#fff; border-color:#295582; background:#3b5998 url(http://b.static.ak.fbcdn.net/images/share/facebook_share_icon.gif?8:26981) no-repeat top right; text-decoration:none;}
</style>
<a href="http://www.facebook.com/share.php?u=http://cyrusbuilt.net/wordpress/?p=320" class="fb_share_button" onclick="return fbs_click()" target="_blank" style="text-decoration:none;">Share</a></div><div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		digg_url = "http://cyrusbuilt.net/wordpress/?p=320";
		digg_bgcolor = "#FFFFFF";
		digg_skin = "";
		digg_window = "";
		digg_title = "A Letter on Behalf of the I.T./Tech Support Professionals Around the World";
		digg_media = "news";
		digg_topic = "";
		digg_bodytext = "";
		//-->
		</script>
		<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script></div><!--S-ButtonZ 1.1.5 End--><p><a href="http://www.pcpro.co.uk/blogs/2011/03/08/a-letter-on-behalf-of-the-worlds-pc-fixers/" target="_blank">This is an absolute </a><strong><a href="http://www.pcpro.co.uk/blogs/2011/03/08/a-letter-on-behalf-of-the-worlds-pc-fixers/" target="_blank">MUST READ</a> </strong>for <strong>everyone</strong>&#8230; not just geeks/I.T. professionals/computer technicians.  What?  Don&#8217;t just sit there reading <strong>this</strong>&#8230; go read <strong><a href="http://www.pcpro.co.uk/blogs/2011/03/08/a-letter-on-behalf-of-the-worlds-pc-fixers/" target="_blank">THAT</a>.</strong></p>
<p>My hats off to you, Steve Cassidy.  You&#8217;ve done a wonderful thing by writing that article, but I fear that while all of us in field fully understand and agree with your plight, those who are not in the field will continue on completely oblivious.  *sigh*</p>
<div style="clear:both;">&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://cyrusbuilt.net/wordpress/?feed=rss2&#038;p=320</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AutoItV3 Project Creator/Editor v1.0.0.4 released</title>
		<link>http://cyrusbuilt.net/wordpress/?p=315</link>
		<comments>http://cyrusbuilt.net/wordpress/?p=315#comments</comments>
		<pubDate>Wed, 16 Feb 2011 15:00:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AutoIt]]></category>
		<category><![CDATA[CyrusBuilt News]]></category>
		<category><![CDATA[CyrusBuilt Software]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://cyrusbuilt.net/wordpress/?p=315</guid>
		<description><![CDATA[Share After receiving some feedback, I&#8217;ve fixed a couple small bugs, and a couple features, and done some code cleanup.  Version 1.0.0.4 is now available for download on the downloads page. Changelog for v1.0.0.4: - [Added] &#8220;Now&#8221; buttons next to both date fields on the &#8220;Details&#8221; tab, which set the fields to the current system [...]]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><div style="float: right; width: 42px; padding-right: 90px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		reddit_url = "http://cyrusbuilt.net/wordpress/?p=315";
		reddit_title = "AutoItV3 Project Creator/Editor v1.0.0.4 released";
		//-->
		</script>
		<script type="text/javascript" src="http://www.reddit.com/button.js?t=1"></script></div><div style="float: right; width: 70px; margin: 0 0 0 10px;">
<script type="text/javascript">
function fbs_click() {
u=location.href;
t=document.title;
window.open("http://www.facebook.com/sharer.php?u="+encodeURIComponent(u)+"&t="+encodeURIComponent(t),"sharer","toolbar=0,status=0,width=626,height=436");
return false;
}
</script>
<style type="text/css">
html .fb_share_button {display: -moz-inline-block; display:inline-block; padding:1px 20px 0 5px; height:15px; border:1px solid #d8dfea; background:url(http://b.static.ak.fbcdn.net/images/share/facebook_share_icon.gif?8:26981) no-repeat top right;}
html .fb_share_button:hover {color:#fff; border-color:#295582; background:#3b5998 url(http://b.static.ak.fbcdn.net/images/share/facebook_share_icon.gif?8:26981) no-repeat top right; text-decoration:none;}
</style>
<a href="http://www.facebook.com/share.php?u=http://cyrusbuilt.net/wordpress/?p=315" class="fb_share_button" onclick="return fbs_click()" target="_blank" style="text-decoration:none;">Share</a></div><div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		digg_url = "http://cyrusbuilt.net/wordpress/?p=315";
		digg_bgcolor = "#FFFFFF";
		digg_skin = "";
		digg_window = "";
		digg_title = "AutoItV3 Project Creator/Editor v1.0.0.4 released";
		digg_media = "news";
		digg_topic = "";
		digg_bodytext = "";
		//-->
		</script>
		<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script></div><!--S-ButtonZ 1.1.5 End--><p>After receiving some feedback, I&#8217;ve fixed a couple small bugs, and a couple features, and done some code cleanup.  Version 1.0.0.4 is now available for download on the <a href="http://cyrusbuilt.net/wordpress/?page_id=55" target="_self">downloads page</a>.</p>
<p>Changelog for v1.0.0.4:<br />
- [Added] &#8220;Now&#8221; buttons next to both date fields on the &#8220;Details&#8221; tab, which set the fields to the current system date.<br />
- [Added] Double-click handlers for both ListView controls in the &#8220;References&#8221; tab (as requested by &#8220;LurchMan&#8221;), but are not yet working (see code comments for details).<br />
- [Fixed] Proper indentation for description lines in header comment in newly created project scripts.<br />
- [Added] This changelog.<br />
- [Fixed] autoit3dir path in au3.properties file for 32bit installations. (Thanks to &#8220;Fantastic&#8221; for reporting this).</p>
<div style="clear:both;">&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://cyrusbuilt.net/wordpress/?feed=rss2&#038;p=315</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AutoItV3 Project Creator/Editor v1.0.03 released</title>
		<link>http://cyrusbuilt.net/wordpress/?p=309</link>
		<comments>http://cyrusbuilt.net/wordpress/?p=309#comments</comments>
		<pubDate>Fri, 11 Feb 2011 16:36:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://cyrusbuilt.net/wordpress/?p=309</guid>
		<description><![CDATA[Share Made some minor improvements and bugfixes.  New version is available in the downloads page.  Additionally, I released my dark theme for SciTE (just called &#8220;Black&#8221;), which is also available in the downloads page.  It&#8217;s a SciTEConfig file, so just copy it to your SciTEConfig directory and then apply using the SciTEConfig tool. See my [...]]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><div style="float: right; width: 42px; padding-right: 90px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		reddit_url = "http://cyrusbuilt.net/wordpress/?p=309";
		reddit_title = "AutoItV3 Project Creator/Editor v1.0.03 released";
		//-->
		</script>
		<script type="text/javascript" src="http://www.reddit.com/button.js?t=1"></script></div><div style="float: right; width: 70px; margin: 0 0 0 10px;">
<script type="text/javascript">
function fbs_click() {
u=location.href;
t=document.title;
window.open("http://www.facebook.com/sharer.php?u="+encodeURIComponent(u)+"&t="+encodeURIComponent(t),"sharer","toolbar=0,status=0,width=626,height=436");
return false;
}
</script>
<style type="text/css">
html .fb_share_button {display: -moz-inline-block; display:inline-block; padding:1px 20px 0 5px; height:15px; border:1px solid #d8dfea; background:url(http://b.static.ak.fbcdn.net/images/share/facebook_share_icon.gif?8:26981) no-repeat top right;}
html .fb_share_button:hover {color:#fff; border-color:#295582; background:#3b5998 url(http://b.static.ak.fbcdn.net/images/share/facebook_share_icon.gif?8:26981) no-repeat top right; text-decoration:none;}
</style>
<a href="http://www.facebook.com/share.php?u=http://cyrusbuilt.net/wordpress/?p=309" class="fb_share_button" onclick="return fbs_click()" target="_blank" style="text-decoration:none;">Share</a></div><div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		digg_url = "http://cyrusbuilt.net/wordpress/?p=309";
		digg_bgcolor = "#FFFFFF";
		digg_skin = "";
		digg_window = "";
		digg_title = "AutoItV3 Project Creator/Editor v1.0.03 released";
		digg_media = "news";
		digg_topic = "";
		digg_bodytext = "";
		//-->
		</script>
		<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script></div><!--S-ButtonZ 1.1.5 End--><p>Made some minor improvements and bugfixes.  New version is available in the <a href="http://cyrusbuilt.net/wordpress/?page_id=55" target="_blank">downloads page</a>.  Additionally, I released my dark theme for SciTE (just called &#8220;Black&#8221;), which is also available in the downloads page.  It&#8217;s a SciTEConfig file, so just copy it to your SciTEConfig directory and then apply using the SciTEConfig tool.</p>
<p>See my <a href="http://cyrusbuilt.net/wordpress/?p=302" target="_self">previous post</a> for details/screenshots.</p>
<div style="clear:both;">&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://cyrusbuilt.net/wordpress/?feed=rss2&#038;p=309</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AutoItV3 Project Creator/Editor Released!</title>
		<link>http://cyrusbuilt.net/wordpress/?p=302</link>
		<comments>http://cyrusbuilt.net/wordpress/?p=302#comments</comments>
		<pubDate>Wed, 02 Feb 2011 17:45:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AutoIt]]></category>
		<category><![CDATA[CyrusBuilt Software]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://cyrusbuilt.net/wordpress/?p=302</guid>
		<description><![CDATA[Share I am proud to announce that I have released AutoItProjectCreator v1.0.0.2 to the public and is now available for download.  AutoItProjectCreator is a tool written entirely in AutoItV3 that is designed to be an addon tool for SciTE that facilitates creating and editing AutoIt &#8220;projects&#8221;.  Currently, AutoIt does not have a full-blown IDE like [...]]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><div style="float: right; width: 42px; padding-right: 90px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		reddit_url = "http://cyrusbuilt.net/wordpress/?p=302";
		reddit_title = "AutoItV3 Project Creator/Editor Released!";
		//-->
		</script>
		<script type="text/javascript" src="http://www.reddit.com/button.js?t=1"></script></div><div style="float: right; width: 70px; margin: 0 0 0 10px;">
<script type="text/javascript">
function fbs_click() {
u=location.href;
t=document.title;
window.open("http://www.facebook.com/sharer.php?u="+encodeURIComponent(u)+"&t="+encodeURIComponent(t),"sharer","toolbar=0,status=0,width=626,height=436");
return false;
}
</script>
<style type="text/css">
html .fb_share_button {display: -moz-inline-block; display:inline-block; padding:1px 20px 0 5px; height:15px; border:1px solid #d8dfea; background:url(http://b.static.ak.fbcdn.net/images/share/facebook_share_icon.gif?8:26981) no-repeat top right;}
html .fb_share_button:hover {color:#fff; border-color:#295582; background:#3b5998 url(http://b.static.ak.fbcdn.net/images/share/facebook_share_icon.gif?8:26981) no-repeat top right; text-decoration:none;}
</style>
<a href="http://www.facebook.com/share.php?u=http://cyrusbuilt.net/wordpress/?p=302" class="fb_share_button" onclick="return fbs_click()" target="_blank" style="text-decoration:none;">Share</a></div><div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		digg_url = "http://cyrusbuilt.net/wordpress/?p=302";
		digg_bgcolor = "#FFFFFF";
		digg_skin = "";
		digg_window = "";
		digg_title = "AutoItV3 Project Creator/Editor Released!";
		digg_media = "news";
		digg_topic = "";
		digg_bodytext = "";
		//-->
		</script>
		<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script></div><!--S-ButtonZ 1.1.5 End--><p>I am proud to announce that I have released AutoItProjectCreator v1.0.0.2 to the public and is now <a href="http://cyrusbuilt.net/wordpress/?page_id=55" target="_blank">available for download</a>.  AutoItProjectCreator is a tool written entirely in <a href="http://www.autoitscript.com/site/autoit/" target="_blank">AutoItV3</a> that is designed to be an addon tool for SciTE that facilitates creating and editing AutoIt &#8220;projects&#8221;.  Currently, AutoIt does not have a full-blown IDE like <a href="http://msdn.microsoft.com/en-us/vstudio/default" target="_blank">Microsoft Visual Studio</a>, but it has many tools that provide much of the functionality that you find in an IDE such as a code editor, form designer, compiler, etc.  Most of these tools can be found either included with AutoIt or included in the <a href="http://www.autoitscript.com/autoit3/scite/" target="_blank">SciTE4AutoIt3 package</a>.</p>
<p>However, as an AutoIt programmer who uses the language to develop both commercial and non-commercial software, whenever I start working on a new program, I create a &#8220;project&#8221;.  I do this with any language I code in.  I define a project as being a folder structure containing source files and documentation related to the program being developed.  So when I start a new AutoIt &#8220;project&#8221; I typically end up manually creating the same folder structure as every other AutoIt project, then the script which I tend to start out the same as every other AutoIt script I write (commonly used #region names, header comment block format, as well as certain constants and functions), and then possibly also create a configuration file and/or installer script if I&#8217;m building a full-blown app.</p>
<p>As a result of this redundancy, I set out looking for a tool worked kind of like Visual Studio in the sense that it creates a folder structure and source files, associates any references, and also stores project specifics in a special file call a &#8220;project file&#8221;.  In VS, you typically have a &#8220;solution&#8221; with one or more &#8220;projects&#8221; in the &#8220;solution&#8221;.  I did not see a need to go as far as implementing a &#8220;solution&#8221; scheme, but the concept of &#8220;projects&#8221; seemed valuable to me.  AutoItProjectCreator is designed to be used as a SciTE4AutoIt3 addon but can also be run standalone.  The installer will also automatically associate the *.au3proj file extension with AutoItProjectCreator so that you can open a project by simply double-clicking on your project&#8217;s project file.</p>
<p>This is the first release&#8230;.. I do not expect it to be perfect&#8230;.. but so far it suits my needs just fine.  If you think you could benefit from such a tool, then I encourage you to download it.  Both <a href="http://cyrusbuilt.net/wordpress/?page_id=55" target="_blank">32bit and 64bit</a> versions are available as well as the source code, all of which is released under <a href="http://www.gnu.org/licenses/gpl-2.0.html" target="_blank">GPL v2</a>.</p>
<p>Enjoy!</p>

<a href='http://cyrusbuilt.net/wordpress/?attachment_id=303' title='aipc1'><img width="150" height="150" src="http://cyrusbuilt.net/wordpress/wp-content/uploads/2011/02/aipc1-150x150.jpg" class="attachment-thumbnail" alt="aipc1" title="aipc1" /></a>
<a href='http://cyrusbuilt.net/wordpress/?attachment_id=304' title='aipc2'><img width="150" height="150" src="http://cyrusbuilt.net/wordpress/wp-content/uploads/2011/02/aipc2-150x150.jpg" class="attachment-thumbnail" alt="aipc2" title="aipc2" /></a>
<a href='http://cyrusbuilt.net/wordpress/?attachment_id=305' title='aipc3'><img width="150" height="150" src="http://cyrusbuilt.net/wordpress/wp-content/uploads/2011/02/aipc3-150x150.jpg" class="attachment-thumbnail" alt="aipc3" title="aipc3" /></a>

<div style="clear:both;">&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://cyrusbuilt.net/wordpress/?feed=rss2&#038;p=302</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

