<?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>Erik Miller .NET</title>
	<atom:link href="http://www.erikmiller.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.erikmiller.net</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Wed, 25 May 2011 14:38:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>CS Games Competition: Game Development (Part 1)</title>
		<link>http://www.erikmiller.net/2011/05/cs-games-competition-game-development-part-1/</link>
		<comments>http://www.erikmiller.net/2011/05/cs-games-competition-game-development-part-1/#comments</comments>
		<pubDate>Wed, 25 May 2011 14:27:01 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[CS Games]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Game Development]]></category>

		<guid isPermaLink="false">http://www.erikmiller.net/?p=42</guid>
		<description><![CDATA[So one of the competitions I worked on for the CS Games this year was Game Development. For this, we provided a 2d platformer based on a sample XNA project provided by Microsoft. The final product provided to students allowed them to do the following: build levels without performing any coding extend the framework by ]]></description>
			<content:encoded><![CDATA[<p>So one of the competitions I worked on for the CS Games this year was Game Development.  For this, we provided a 2d platformer based on a sample XNA project provided by Microsoft.  The final product provided to students allowed them to do the following:</p>
<ul>
<li>build levels without performing any coding</li>
<li>extend the framework by making additional AIs, items, tiles, anything they wanted to customize their game</li>
<li>choose from a large variety of sprites/sound effects/visual effects to give the game a more unique feel.</li>
</ul>
<p>Something to keep in mind with all the submissions, competitors only had 3 hours to produce something, given the time limit, I&#8217;m really pleased with what came out of it at the end and I think everyone had a really good time.</p>
<p>Check out the following video to see some of the cool stuff people came up with.</p>
<p><iframe width="560" height="349" src="http://www.youtube.com/embed/QbQhV2fJX_4" frameborder="0" allowfullscreen></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://www.erikmiller.net/2011/05/cs-games-competition-game-development-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C# Events and Garbage Collection</title>
		<link>http://www.erikmiller.net/2010/12/c-events-and-garbage-collection/</link>
		<comments>http://www.erikmiller.net/2010/12/c-events-and-garbage-collection/#comments</comments>
		<pubDate>Wed, 15 Dec 2010 17:39:00 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://www.erikmiller.net/?p=17</guid>
		<description><![CDATA[A friend asked me earlier about garbage collection in C#.  What happens to an object with Events when we set it to null, will the references in the event prevent it from being GCed? Lets say we&#8217;ve got 2 classes, Listener and Generator.  Generator has an event called SayMyName and each Listener registers to that ]]></description>
			<content:encoded><![CDATA[<p>A friend asked me earlier about garbage collection in C#.  What happens to an object with Events when we set it to null, will the references in the event prevent it from being GCed?</p>
<p>Lets say we&#8217;ve got 2 classes, <em><strong>Listener</strong></em> and <em><strong>Generator</strong></em>.  <em><strong>Generator </strong></em>has an event called <em>SayMyName</em> and each Listener registers to that event when it gets created.</p>
<p>Notice in the <em><strong>Listener</strong></em> class we dont actually store the Generator in a class level variable (or property). What links these two together is stored in the Generator reference to the <em><strong>Listener</strong></em> is added to the <em><strong>Generator</strong></em></p>
<pre class="qoate-code">public class Listener
{
	static List instances = new List();

	public Listener(Generator generator)
	{
		instances.Add(new WeakReference(this));
		generator.SayMyName += new Generator.SayMyNameHandler(Generator_MyEvent);
	}

	void Generator_MyEvent(string name)
	{
		Console.WriteLine(name);
	}

	public static void TestReferences()
	{
		int cnt = 0;
		foreach (WeakReference instance in instances)
		{
			Console.WriteLine("Instance " + (cnt++) + " is " + (instance.IsAlive ? " alive " : " gone"));
		}
	}
}
</pre>
<p>Now for the Generator class, we&#8217;re going to do something a bit special.  We&#8217;re going to create a static List of <em><strong>WeakReference</strong></em>s to keep track of the instances and whether they&#8217;ve actually been disposed of by the Garbage Collector.  <em><strong>WeakReference</strong></em>s are ignored when counting references on an object during garbage collection.</p>
<pre class="qoate-code">
public class Generator
{
	static List instances = new List();

	private string _name = null;
	public string Name {
		get
		{
			return _name;
		}
		set
		{
			_name = value;
			OnSayMyName();
		}
	}

	public event SayMyNameHandler SayMyName;
	public delegate void SayMyNameHandler(string name);

	public Generator()
	{
		instances.Add(new WeakReference(this));
	}

	protected void OnSayMyName()
	{
		if (SayMyName != null)
			SayMyName(Name);
	}

	public static void TestReferences()
	{
		int cnt = 0;
		foreach (WeakReference instance in instances)
		{
			Console.WriteLine("Instance " + (cnt++) + " is " + (instance.IsAlive ? " alive " : " gone"));
		}
	}
}
</pre>
<p>Now lets try actually making use of these, then try to remove our Generator.</p>
<pre class="qoate-code">
Generator generator = new Generator();
Listener listener = new Listener(generator);

Console.WriteLine("Generator References:");
Generator.TestReferences();
Console.WriteLine("Listener References:");
Listener.TestReferences();

generator = null;
GC.WaitForFullGCComplete();

//No Generator instances will remain, Listener has no reference to Generator
Console.WriteLine("Generator References:");
Generator.TestReferences();
Console.WriteLine("Listener References:");
Listener.TestReferences();
</pre>
<p>Alternatively, the same cannot be said if we want to get rid of a Listener so easily.</p>
<pre class="qoate-code">
Generator generator = new Generator();
Listener listener = new Listener(generator);

Console.WriteLine("Generator References:");
Generator.TestReferences();
Console.WriteLine("Listener References:");
Listener.TestReferences();

listener = null;
GC.WaitForFullGCComplete();

//Listener instance remains because the reference is held by the Event.
Console.WriteLine("Generator References:");
Generator.TestReferences();
Console.WriteLine("Listener References:");
Listener.TestReferences();
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.erikmiller.net/2010/12/c-events-and-garbage-collection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Coding Night of Horrors</title>
		<link>http://www.erikmiller.net/2009/02/coding-night-of-horrors/</link>
		<comments>http://www.erikmiller.net/2009/02/coding-night-of-horrors/#comments</comments>
		<pubDate>Mon, 23 Feb 2009 19:51:11 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Game Development]]></category>
		<category><![CDATA[SCS]]></category>
		<category><![CDATA[caffeine]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[gaming]]></category>

		<guid isPermaLink="false">http://www.erikmiller.net/?p=10</guid>
		<description><![CDATA[On Saturday night, 11 brave souls sat down for an all night event of coding, pizza, and caffeine. Needless to say horrors, wonders, and uncertainties were produced. Some worked on their individual projects, others worked on a joint effort of producing something from scratch. I introduce to you the SCS World Simulator. A joint project ]]></description>
			<content:encoded><![CDATA[<p>On Saturday night, 11 brave souls sat down for an all night event of coding, pizza, and caffeine. Needless to say horrors, wonders, and uncertainties were produced. Some worked on their individual projects, others worked on a joint effort of producing something from scratch.</p>
<p>I introduce to you the SCS World Simulator. A joint project started at 8pm Saturday evening and finished at 7am Sunday morning. Given a small framework to get the project started, a goal, and a lot of caffeine these people were tasked with building a world, characters, AIs (Artificial Intelligences) to control them, a combat system, a method of communication&#8230;. and then let the creations run wild and see what happens.</p>
<p>Our conclusion? IT&#8217;S ALIVE!!!! People created custom looking characters with their own intelligence (after a fashion). We had ninjas, pirates, pikachus, normal people, bombs, querie-some bears, hobos and dancing Darth Vaderites. Each did their own thing, some interacting verbally, others interacting with a sword, and others that just sat and danced.</p>
<p>Scared to see what comes of this? next week at engineering week we&#8217;ll be setup and showing off our little project. We&#8217;ll let it run for some hours to see what these wee devils come up with on their own. A big thank you and congratulations to those who participated. To those who missed it? Don&#8217;t worry, we&#8217;ll do it again!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.erikmiller.net/2009/02/coding-night-of-horrors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

