<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Progressive Digressive</title>
	
	<link>http://www.marcuswhitworth.com</link>
	<description>Marcus Whitworth's tech blog – .NET, C#, Silverlight, WPF, Flex…etc, etc</description>
	<lastBuildDate>Wed, 14 Dec 2011 16:14:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/MarcusWhitworth" /><feedburner:info uri="marcuswhitworth" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Settings shortcuts for iOS</title>
		<link>http://feedproxy.google.com/~r/MarcusWhitworth/~3/F3pW1TZZtPA/</link>
		<comments>http://www.marcuswhitworth.com/2011/12/settings-shortcuts-for-ios/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 16:12:32 +0000</pubDate>
		<dc:creator>Marcus</dc:creator>
				<category><![CDATA[Useful]]></category>
		<category><![CDATA[iOS]]></category>

		<guid isPermaLink="false">http://www.marcuswhitworth.com/?p=244</guid>
		<description><![CDATA[Now that i&#8217;m back on an iPhone, these settings shortcuts are quite handy &#8211; add icons for often-accessed settings to your home screen.]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p><img class="alignright size-full wp-image-245" title="iOS settings shortcuts" src="http://www.marcuswhitworth.com/wp-content/uploads/2011/12/settings-banner-e1323878876224.jpg" alt="iOS settings shortcuts" width="400" height="162" />Now that <a href="http://www.marcuswhitworth.com/2011/11/another-nokia-lumia-800-with-windows-phone-7-review/" target="_blank">i&#8217;m back on an iPhone</a>, <a href="http://brdrck.me/settings/" target="_blank">these settings shortcuts</a> are quite handy &#8211; add icons for often-accessed settings to your home screen.</p>
<div class="shr-publisher-244"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.marcuswhitworth.com%2F2011%2F12%2Fsettings-shortcuts-for-ios%2F' data-shr_title='Settings+shortcuts+for+iOS'></a><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.marcuswhitworth.com%2F2011%2F12%2Fsettings-shortcuts-for-ios%2F' data-shr_title='Settings+shortcuts+for+iOS'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic --><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/MarcusWhitworth?a=F3pW1TZZtPA:cKRey2CU9EU:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/MarcusWhitworth?i=F3pW1TZZtPA:cKRey2CU9EU:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/MarcusWhitworth/~4/F3pW1TZZtPA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.marcuswhitworth.com/2011/12/settings-shortcuts-for-ios/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.marcuswhitworth.com/2011/12/settings-shortcuts-for-ios/</feedburner:origLink></item>
		<item>
		<title>Another Nokia Lumia 800 with Windows Phone 7 review…</title>
		<link>http://feedproxy.google.com/~r/MarcusWhitworth/~3/QdRFtb1DI3A/</link>
		<comments>http://www.marcuswhitworth.com/2011/11/another-nokia-lumia-800-with-windows-phone-7-review/#comments</comments>
		<pubDate>Tue, 29 Nov 2011 16:20:44 +0000</pubDate>
		<dc:creator>Marcus</dc:creator>
				<category><![CDATA[Reviews]]></category>
		<category><![CDATA[wp7]]></category>

		<guid isPermaLink="false">http://www.marcuswhitworth.com/?p=227</guid>
		<description><![CDATA[I&#8217;ve been looking forward to the Nokia Lumia release for several months now.  I had an iPhone 3gs which was starting to drive me crazy with an unfortunate habit of restarting any time I was on the phone for longer &#8230; <a href="http://www.marcuswhitworth.com/2011/11/another-nokia-lumia-800-with-windows-phone-7-review/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p><img class="alignright size-full wp-image-237" title="Nokia-Lumia-800" src="http://www.marcuswhitworth.com/wp-content/uploads/2011/11/Nokia-Lumia-800.jpg" alt="Nokia-Lumia-800" width="200" height="142" />I&#8217;ve been looking forward to the Nokia Lumia release for several months now.  I had an iPhone 3gs which was starting to drive me crazy with an unfortunate habit of restarting any time I was on the phone for longer than a few minutes, so having read overwhelmingly positive reviews of both WP7 and the just-released Nokia devices, I was keen to ditch my iPhone and give them a shot.</p>
<p>I&#8217;ve had my Lumia for a few weeks now, and whilst there&#8217;s several things I really like about it, and particularly the WP7 system, there&#8217;s unfortunately a number of gripes that are fast becoming showstoppers.</p>
<p><span style="color: #ff9900;"><strong>Positives</strong>:</span></p>
<ol>
<li>I <em>really</em> like the WP7 interface.  It&#8217;s slick, very intuitive, and well integrated.</li>
<li>I&#8217;m not an avid facebook user, but I like the integration it has, meaning I never really need to log into FB at all anymore.</li>
<li>The Lumia 800 handset is really nice.  A well formed piece of kit.</li>
<li>As a developer, there&#8217;s a lot of scope for creating apps &#8211; the MarketPlace is well stocked, but there is a number of missing elements, and many of the ones there are poorly written.</li>
</ol>
<p><span style="color: #ff9900;"><strong>Negatives</strong>:</span></p>
<p><span style="color: #ff9900;">Handset</span></p>
<p>The <a href="http://discussions.europe.nokia.com/t5/Nokia-with-Windows-Phone/Lumia-800-poor-battery-life/td-p/1217129/page/15" target="_blank">handset battery life sucks</a>, to the point of being unusable.  At best I&#8217;ll get around 10 hrs out of it with light-moderate use.  One day I got less than 8.  With the same usage for my 2 year old iPhone 3gs, I typically got around 18 hrs &#8211; still not great, but at least usable.  Clearly there&#8217;s some sort of bug in the firmware or software, but I find it hard to believe they passed any sort of QA process in this state.</p>
<p><span style="color: #ff9900;">Mail</span></p>
<p>I use Gmail, and the interop between the WP7 mail app and Gmail is sub-standard.  I&#8217;ve tried both setting up my mail with the suggested Google account setup, and as an Exchange account, but problems still make it hugely frustrating:</p>
<ul>
<li>Deleting a message doesn&#8217;t delete it in your Gmail account, it just archives it.  I recall this was also an issue with my iPhone, but you could still force it to delete messages with Imap setup.  Nobody seems to have come up with a solution for WP7, so I&#8217;m left to log into Gmail every few days to delete the messages that should have already been deleted.</li>
<li>You can&#8217;t cap the max number of messages downloaded.  If I set my mail to sync for Any time (instead of just past month etc), then sync my All Mail folder, it proceeds to download ALL the mail from my Gmail account.  That&#8217;s a lot of messages.  Once again, on iOS I could specify the number of messages I want to display at once to avoid downloading EVERYTHING.  I want to be able to view messages older than the past month, but I also don&#8217;t want every single message in my Gmail downloaded at once.</li>
</ul>
<p><span style="color: #ff9900;">Various WP7 annoyances</span></p>
<ul>
<li>The Alarm.  Much like the iOS alarm with one key difference &#8211; you can&#8217;t set the volume!  It&#8217;s just loud, regardless of what your ring volume is set to.  Not really usable when you don&#8217;t want to wake up everyone else each morning.</li>
<li>No screen rotation lock.</li>
<li>No battery % indicator &#8211; it&#8217;d be very useful when your battery is as bad as it is and you don&#8217;t really know at a glance whether you have 25% or 10% remaining.</li>
<li>The keyboard.  It&#8217;s certainly not bad, and much better than Android devices that I&#8217;ve used, but after 2 weeks I&#8217;m about twice as slow as I was on iOS, and making numerous mistakes.  Don&#8217;t think by now it&#8217;s something I&#8217;m going to get used to &#8211; it&#8217;s just not as easy to use as the iOS keyboard.</li>
</ul>
<p>I have fairly simple requirements for a smartphone &#8211; make calls, manage email easily, maps, alarms, and some music.  Unfortunately my Lumia isn&#8217;t currently stacking up as either a mail platform (due to both aforementioned mail issues, and slowness of keyboard use), or for alarms.  Of course, the battery issue is a complete showstopper &#8211; I hope it&#8217;ll get resolved soon by Nokia, but I&#8217;m certainly not going to bet anything on it.</p>
<p>I really wanted it to work.  I don&#8217;t want to go back to iOS.  But at the moment, I&#8217;m not sure I&#8217;m left with much choice!</p>
<div class="shr-publisher-227"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.marcuswhitworth.com%2F2011%2F11%2Fanother-nokia-lumia-800-with-windows-phone-7-review%2F' data-shr_title='Another+Nokia+Lumia+800+with+Windows+Phone+7+review...'></a><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.marcuswhitworth.com%2F2011%2F11%2Fanother-nokia-lumia-800-with-windows-phone-7-review%2F' data-shr_title='Another+Nokia+Lumia+800+with+Windows+Phone+7+review...'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic --><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/MarcusWhitworth?a=QdRFtb1DI3A:KvfXHGOyLy0:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/MarcusWhitworth?i=QdRFtb1DI3A:KvfXHGOyLy0:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/MarcusWhitworth/~4/QdRFtb1DI3A" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.marcuswhitworth.com/2011/11/another-nokia-lumia-800-with-windows-phone-7-review/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.marcuswhitworth.com/2011/11/another-nokia-lumia-800-with-windows-phone-7-review/</feedburner:origLink></item>
		<item>
		<title>iTunes to Zune playlist converter app for Windows Phone 7</title>
		<link>http://feedproxy.google.com/~r/MarcusWhitworth/~3/Sfpbf70xHog/</link>
		<comments>http://www.marcuswhitworth.com/2011/11/itunes-to-zune-playlist-converter-app-for-windows-phone-7-use/#comments</comments>
		<pubDate>Sun, 27 Nov 2011 22:18:07 +0000</pubDate>
		<dc:creator>Marcus</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[wp7]]></category>

		<guid isPermaLink="false">http://www.marcuswhitworth.com/?p=212</guid>
		<description><![CDATA[I moved from an iPhone to a WP7 device recently, and one of niggles in the move was getting my iTunes playlists imported into Zune.  Doesn&#8217;t seem like there&#8217;s a simple way to accomplish this, so I created a small &#8230; <a href="http://www.marcuswhitworth.com/2011/11/itunes-to-zune-playlist-converter-app-for-windows-phone-7-use/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>I moved from an iPhone to a WP7 device recently, and one of niggles in the move was getting my iTunes playlists imported into Zune.  Doesn&#8217;t seem like there&#8217;s a simple way to accomplish this, so I created a small windows app to do it for me.</p>
<p>You can download it below.  Just run it (you&#8217;ll need .NET 4 framework installed), and it should detect your iTunes playlists automatically.  It won&#8217;t import m4p files in your playlists, as they&#8217;re DRM protected and can only be played via iTunes.</p>
<p><img src="http://www.marcuswhitworth.com/wp-content/uploads/2011/11/ITunesToZunePlaylistConverter-Running-Microsoft-Visual-Studio-Administrator_2011-11-27_22-22-41.png" alt="" width="600" /></p>
<p>You can <a href="https://skydrive.live.com/redir.aspx?cid=2766a525cd9fa8ec&#038;resid=2766A525CD9FA8EC!223" target="_blank">download the application for your own use here</a>.</p>
<div class="shr-publisher-212"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.marcuswhitworth.com%2F2011%2F11%2Fitunes-to-zune-playlist-converter-app-for-windows-phone-7-use%2F' data-shr_title='iTunes+to+Zune+playlist+converter+app+for+Windows+Phone+7'></a><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.marcuswhitworth.com%2F2011%2F11%2Fitunes-to-zune-playlist-converter-app-for-windows-phone-7-use%2F' data-shr_title='iTunes+to+Zune+playlist+converter+app+for+Windows+Phone+7'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic --><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/MarcusWhitworth?a=Sfpbf70xHog:-nuyx2pkQcg:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/MarcusWhitworth?i=Sfpbf70xHog:-nuyx2pkQcg:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/MarcusWhitworth/~4/Sfpbf70xHog" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.marcuswhitworth.com/2011/11/itunes-to-zune-playlist-converter-app-for-windows-phone-7-use/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.marcuswhitworth.com/2011/11/itunes-to-zune-playlist-converter-app-for-windows-phone-7-use/</feedburner:origLink></item>
		<item>
		<title>Rx – System Time and Scheduler issues</title>
		<link>http://feedproxy.google.com/~r/MarcusWhitworth/~3/gdVWAAy9wCo/</link>
		<comments>http://www.marcuswhitworth.com/2011/09/rx-system-time-and-scheduler-issues/#comments</comments>
		<pubDate>Wed, 14 Sep 2011 16:36:06 +0000</pubDate>
		<dc:creator>Marcus</dc:creator>
				<category><![CDATA[Bugs]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[rx]]></category>

		<guid isPermaLink="false">http://www.marcuswhitworth.com/?p=188</guid>
		<description><![CDATA[I recently had an issue with time-dependent methods of Rx, which were adversely affected when a user changed their system clock.  You can read up on the history on the Rx forums. In the older Rx v1.0.2787 (which my current &#8230; <a href="http://www.marcuswhitworth.com/2011/09/rx-system-time-and-scheduler-issues/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>I recently had an issue with time-dependent methods of Rx, which were adversely affected when a user changed their system clock.  You can read up on the history <a href="http://social.msdn.microsoft.com/Forums/en/rx/thread/672a9b1d-c25e-4797-ad24-5f3252089df0" target="_blank">on the Rx forums</a>.</p>
<p>In the older Rx v1.0.2787 (which my current project is still using), <em>BufferWithTime</em> was affected, along with other methods such as <em>Interval, Timer, </em>and<em> Sample. </em></p>
<p>The most problematic for my purposes was <em>BufferWithTime</em><em>. </em> For instance, if you shift the system clock back and then push values onto the Buffer, the values are then either lost completely or they arrive late.  If you shift the clock forward a significant amount, Rx overloads the CPU pushing through potentially thousands of empty updates in an effort to catch up with the new clock time.  Worse still, if you shift your clock back several years then you get an UnhandledException along the lines of &#8220;Time-out interval must be less than 2^32-2&#8243;.</p>
<p>In the latest Rx v1.1.10621 (experimental), it seems neither <em>Buffer </em>nor <em>Window</em> are affected, but <em>Interval, Timer, </em>and<em> Sample</em> are.</p>
<p>In short, the issue is that all problematic methods are dependent upon <em>IScheduler.Now</em>.  In all <em>IScheduler</em> implementations, this property just returns <em>DateTimeOffset.Now</em>, which is of course straight from the system clock.  Change the system clock, and subsequent reads of <em>IScheduler.Now</em> will return times not in line with previous values.</p>
<p>The solution was to implement a custom <em>IScheduler</em>.  I&#8217;ve quite literally copied the <em>ThreadPoolScheduler</em> source, and simply modified the <em>Now</em> property implementation.</p>
<p>In my implementation below, you can see that I start a <em>Stopwatch</em> during construction, and use this to determine the actual time in the getter for <em>Now</em>.  From my testing it behaves correctly in all situations where I was previously missing notifications.  The relevant parts are the constructor and the <em>Now</em> getter, all other methods are simply a copy of the <em>ThreadPoolScheduler</em>.</p>
<p><a href="http://www.marcuswhitworth.com/wp-content/uploads/2011/09/RxTimerTests.zip">Attached here</a> is a sample project demonstrating both the issue and the fix for the latest Rx release.  Just run it and hit the &#8220;-10 secs&#8221; button to shift your system clock back.</p>
<p>Thoughts and comments welcome&#8230;</p>
<pre class="brush:csharp">public class AccurateTimeScheduler : IScheduler, IDisposable
{
	private static readonly object _gate = new object();
	private static readonly Dictionary&lt;Timer, object&gt; _timers 
		= new Dictionary&lt;Timer, object&gt;();

	private readonly Stopwatch _stopWatch = new Stopwatch();
	private DateTimeOffset _startTime;

	public AccurateTimeScheduler()
	{
		_startTime = DateTimeOffset.Now;
		_stopWatch.Start();
	}

	public DateTimeOffset Now
	{
		get
		{
			var dateTimeOffset = _startTime.AddMilliseconds(
				_stopWatch.ElapsedMilliseconds);

			Trace.WriteLine(
				string.Format("Now: Default={0}, Corrected={1}",
					            DateTimeOffset.Now.ToString("HH:mm:ss.fff"),
					            dateTimeOffset.ToString("HH:mm:ss.fff")));
			return _startTime.AddMilliseconds(_stopWatch.ElapsedMilliseconds);
		}
	}

	public IDisposable Schedule&lt;TState&gt;(TState state, Func&lt;IScheduler, TState, IDisposable&gt; action)
	{
		if (action == null)
			throw new ArgumentNullException("action");
		var d = new SingleAssignmentDisposable();
		ThreadPool.QueueUserWorkItem(
			_ =&gt;
				{
					if (d.IsDisposed)
						return;
					d.Disposable = action((IScheduler) this, state);
				}, null);
		return d;
	}

	public IDisposable Schedule&lt;TState&gt;(TState state, TimeSpan dueTime, Func&lt;IScheduler, TState, IDisposable&gt; action)
	{
		if (action == null)
			throw new ArgumentNullException("action");
		var dueTime1 = Scheduler.Normalize(dueTime);
		if (dueTime1.Ticks == 0L)
			return Schedule(state, action);
		var hasAdded = false;
		var hasRemoved = false;
		var d = new MultipleAssignmentDisposable();
		Timer timer = null;
		timer = new Timer(
			_ =&gt;
				{
					Func&lt;IScheduler, TState, IDisposable&gt; localAction;
					lock (_gate)
					{
						if (hasAdded &amp;&amp; timer != null)
							_timers.Remove(timer);
						localAction = action;
					}
					var localTimer = timer;
					if (localTimer != null)
						localTimer.Dispose();
					timer = null;
					if (localAction != null)
					{
						d.Disposable = localAction((IScheduler) this, state);
						Trace.WriteLine("Executing");
					}
					action = null;
				}, null, dueTime1, TimeSpan.FromMilliseconds(-1.0));

		lock (_gate)
		{
			if (!hasRemoved)
			{
				_timers.Add(timer, null);
				hasAdded = true;
			}
		}

		d.Disposable = Disposable.Create(
			() =&gt;
				{
					var localTimer = timer;
					if (localTimer != null)
					{
						localTimer.Dispose();
						lock (_gate)
						{
							_timers.Remove(localTimer);
							action = null;
						}
					}
					timer = null;
				});
		return d;
	}

	public IDisposable Schedule&lt;TState&gt;(
TState state, DateTimeOffset dueTime, Func&lt;IScheduler, TState, IDisposable&gt; action)
	{
		if (action == null)
			throw new ArgumentNullException("action");

		return Schedule(state, dueTime - Now, action);
	}

	public void Dispose()
	{
		_stopWatch.Stop();
	}
}</pre>
<div class="shr-publisher-188"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.marcuswhitworth.com%2F2011%2F09%2Frx-system-time-and-scheduler-issues%2F' data-shr_title='Rx+-+System+Time+and+Scheduler+issues'></a><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.marcuswhitworth.com%2F2011%2F09%2Frx-system-time-and-scheduler-issues%2F' data-shr_title='Rx+-+System+Time+and+Scheduler+issues'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic --><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/MarcusWhitworth?a=gdVWAAy9wCo:SGEBq4L0inA:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/MarcusWhitworth?i=gdVWAAy9wCo:SGEBq4L0inA:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/MarcusWhitworth/~4/gdVWAAy9wCo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.marcuswhitworth.com/2011/09/rx-system-time-and-scheduler-issues/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.marcuswhitworth.com/2011/09/rx-system-time-and-scheduler-issues/</feedburner:origLink></item>
		<item>
		<title>Avoiding memory leaks with easier disposal</title>
		<link>http://feedproxy.google.com/~r/MarcusWhitworth/~3/soj_eyz3ETQ/</link>
		<comments>http://www.marcuswhitworth.com/2010/12/avoiding-memory-leaks-with-easier-disposal/#comments</comments>
		<pubDate>Fri, 03 Dec 2010 11:48:07 +0000</pubDate>
		<dc:creator>Marcus</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[rx]]></category>

		<guid isPermaLink="false">http://www.marcuswhitworth.com/?p=165</guid>
		<description><![CDATA[One of the biggest causes of memory leaks in .NET applications (or any application), are event handlers remaining active beyond the lifetime of the parent object.  Your object goes out of scope, but continues to listen for events on other &#8230; <a href="http://www.marcuswhitworth.com/2010/12/avoiding-memory-leaks-with-easier-disposal/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>One of the biggest causes of memory leaks in .NET applications (or any application), are event handlers remaining active beyond the lifetime of the parent object.  Your object goes out of scope, but continues to listen for events on other objects, and hence can&#8217;t be garbage collected.  Typically, your class would implement <em>IDisposable</em>, and you&#8217;d remove all your event handlers in that method.  This works fine &#8211; if you keep track of all event handlers and remember to add the corresponding handler removal into your <em>Dispose</em> method.</p>
<p>Two more recent .NET developments which make this process easier to manage are the <em>CompositeDisposable</em> class, and of course <em>IObservable</em>, both of which can be found in the <a href="http://msdn.microsoft.com/en-us/devlabs/ee794896.aspx" target="_blank">Reactive Extensions (Rx)</a> assemblies.</p>
<p><em>CompositeDisposable</em> is simple &#8211; it&#8217;s just a collection of <em>IDisposable</em> objects.  When you call <em>Dispose</em> on your <em>CompositeDisposable</em>, all the items in the collection are disposed.  If you create a BaseDisposable class to be used a base for all your business classes, then you can have something like the following:</p>
<pre class="brush:csharp">public abstract class BaseDisposable : IDisposable
{
	protected CompositeDisposable Disposables = new CompositeDisposable();

	public bool IsDisposed { get; private set; }

	public virtual void Dispose()
	{
		using (Disposables)
		{
			Disposables = null;
		}
		IsDisposed = true;
	}
}

public class MyViewModel : BaseDisposable
{
	public MyViewModel()
	{
		var timer = Observable.Interval(TimeSpan.FromSeconds(1))
			.Subscribe(OnTimerCallback);
		Disposables.Add(timer);
	}

	private void OnTimerCallback(long count)
	{
		Trace.WriteLine(count.ToString());
	}
}</pre>
<p>In the above sample, the <em>MyViewModel</em> class inherits <em>BaseDisposable</em>, so when it is disposed, anything that has been added to the Disposables collection during it&#8217;s lifetime will also be disposed &#8211; no need to add a new Dispose method with lots of event handler removals.  I&#8217;ve just used a simple <em>IObservable</em> subscription in this example, and I haven&#8217;t implemented the Dispose pattern on my <em>BaseDisposable</em> &#8211; which would be a good idea in a real world scenario.  In <em>BaseDisposable</em>, there&#8217;s also an <em>IsDisposed</em> property available &#8211; this can be useful for unit tests to confirm whether your object has been disposed as expected.</p>
<p>It&#8217;s not anything ground breaking, but it will mean you don&#8217;t have to add a Dispose method to each of your classes with lots of handler removals and disposing of child disposables.  In short, cleaner and more maintainable.</p>
<p><em>IObservables</em> work particularly well with this pattern, as each Rx subscription implements <em>IDisposable</em>.  Concurrency, composition, and declarative syntax aside, this alone is a compelling reason to consider using Rx in place of regular event handlers in your application.  Rather than specifying the handler removal in your Dispose method, just add your subscription to the Disposables collection, and the handler will be removed when your object is disposed.</p>
<div class="shr-publisher-165"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.marcuswhitworth.com%2F2010%2F12%2Favoiding-memory-leaks-with-easier-disposal%2F' data-shr_title='Avoiding+memory+leaks+with+easier+disposal'></a><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.marcuswhitworth.com%2F2010%2F12%2Favoiding-memory-leaks-with-easier-disposal%2F' data-shr_title='Avoiding+memory+leaks+with+easier+disposal'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic --><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/MarcusWhitworth?a=soj_eyz3ETQ:iRdOb0OrL8A:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/MarcusWhitworth?i=soj_eyz3ETQ:iRdOb0OrL8A:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/MarcusWhitworth/~4/soj_eyz3ETQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.marcuswhitworth.com/2010/12/avoiding-memory-leaks-with-easier-disposal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.marcuswhitworth.com/2010/12/avoiding-memory-leaks-with-easier-disposal/</feedburner:origLink></item>
		<item>
		<title>Dynamic Linq with Expression Trees</title>
		<link>http://feedproxy.google.com/~r/MarcusWhitworth/~3/lFWZCYWP-Nk/</link>
		<comments>http://www.marcuswhitworth.com/2009/12/dynamic-linq-with-expression-trees/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 19:28:16 +0000</pubDate>
		<dc:creator>Marcus</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[expression trees]]></category>
		<category><![CDATA[linq]]></category>

		<guid isPermaLink="false">http://www.marcuswhitworth.com/?p=106</guid>
		<description><![CDATA[I recently came across a project requirement for the client to create custom validation rules for retrieving data from the SQL database. The rules needed be applied against any number of member applications, and can be altered by the client &#8230; <a href="http://www.marcuswhitworth.com/2009/12/dynamic-linq-with-expression-trees/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>I recently came across a project requirement for the client to create custom validation rules for retrieving data from the SQL database.  The rules needed be applied against any number of member applications, and can be altered by the client at any point.</p>
<p>From the client perspective, the administration of the rules would look something like the following:</p>
<p><img class="aligncenter size-full wp-image-110" title="Rules Administration" src="http://www.marcuswhitworth.com/wp-content/uploads/2009/12/Screen-shot-2009-12-02-at-15.19.47.png" alt="Rules Administration" width="477" height="125" /></p>
<p>Simple enough concept.  Historically, given such a requirement, you&#8217;d likely end up with some fudged SQL string (if querying a database), and/or a whole lot of conditional logic.  The application already uses Linq2SQL, so I didn&#8217;t want to go backwards by introducing some extensive SQL string generation.</p>
<p>The first Linq based option I came across was the <a href="http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx" target="_blank">Dynamic Linq Query Library</a>, which essentially enables you to use SQL-like strings as expressions in your conditional clauses.  Nice, but it still smelled a bit like the SQL string concatenation of old.</p>
<p>The second option I looked at was <a href="http://www.albahari.com/nutshell/predicatebuilder.aspx" target="_blank">PredicateBuilder</a>.  It&#8217;s a neat solution for the right problem, but it assumes that you know the properties/columns you&#8217;re querying against at compile time.</p>
<p>So, I decided to have a play around with Expression Trees, in an effort to dynamically generate my conditional expressions at runtime.  I hadn&#8217;t really delved much into this area before, so I figured it&#8217;d be a good learning experience, even if it didn&#8217;t end up working out.  To cut to the chase, the method I ended up with for parsing my rules into Lambda Expressions looks like the following:</p>
<pre  class="brush:csharp">public static Expression&lt;Func&lt;T, bool&gt;&gt; GetExpression&lt;T&gt;(
	string propertyName, string operatorType, string propertyValue)
{
	var isNegated = operatorType.StartsWith("!");
	if (isNegated)
		operatorType = operatorType.Substring(1);

	var parameter = Expression.Parameter(typeof (T), "type");
	var property = Expression.Property(parameter, propertyName);

	// Cast propertyValue to correct property type
	var td = TypeDescriptor.GetConverter(property.Type);
	var constantValue = Expression.Constant(td.ConvertFromString(propertyValue), property.Type);

	// Check if specified method is an Expression member
	var operatorMethod = typeof(Expression).GetMethod(operatorType, new[] { typeof(MemberExpression), typeof(ConstantExpression) });

	Expression expression;

	if (operatorMethod == null)
	{
		// Execute against type members
		var method = property.Type.GetMethod(operatorType, new[] {property.Type});
		expression = Expression.Call(property, method, constantValue);
	}
	else
	{
		// Execute the passed operator method (e.g. Expression.GreaterThan)
		expression = (Expression) operatorMethod.Invoke(null, new object[] {property, constantValue});
	}

	if (isNegated)
		expression = Expression.Not(expression);

	return Expression.Lambda&lt;Func&lt;T, bool&gt;&gt;(expression, parameter);
}</pre>
<p>Which can be executed with a call like the following:</p>
<pre class="brush:csharp">foreach (var rule in rules)
{
	applicants = applicants.Where(
		GetExpression&lt;Applicant&gt;(
			rule.MemberName, // The Applicant property
			rule.Operator, // Equals, Contains, GreaterThan, etc
			rule.Value)
		);
}</pre>
<p>The rules are looped over, and Linq does its magic by combining all the separate rules with AND statements in the resulting query.</p>
<p>A few things to note:</p>
<ul>
<li>Operators are just the method names to be called, against the Expression type, or any other CLR or custom type.  If you put a ! in front of the operator, it negates the method result (!Contains would read &#8216;Does Not Contain&#8217;).</li>
<li>Reflection isn&#8217;t necessary for building an expression, I just use it here to enable runtime operator implementation, against both the Expression class and potentially any other class.</li>
<li>If you wanted to combine your rules with OR statements, it could be done easily enough with logic similar to what PredicateBuilder uses.</li>
<li>There is possibly/probably better ways to do this &#8211; if you know one, speak up!</li>
</ul>
<p>Is this necessarily any better than using the Dynamic Linq library?  A bit &#8211; it doesn&#8217;t really give me any compile-time type safety benefits, but I could potentially handle certain exceptions that I perhaps wouldn&#8217;t be able to detect using Dynamic Linq, such as casting the value to the correct type.  On top of that, I like it more, it <em>feels</em> more robust, and doesn&#8217;t require external libraries to work.  If nothing else, it gave me an excuse to get my head around some lower-level Expression Tree stuff :)</p>
<div class="shr-publisher-106"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.marcuswhitworth.com%2F2009%2F12%2Fdynamic-linq-with-expression-trees%2F' data-shr_title='Dynamic+Linq+with+Expression+Trees'></a><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.marcuswhitworth.com%2F2009%2F12%2Fdynamic-linq-with-expression-trees%2F' data-shr_title='Dynamic+Linq+with+Expression+Trees'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic --><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/MarcusWhitworth?a=lFWZCYWP-Nk:cHl7r6kQO5E:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/MarcusWhitworth?i=lFWZCYWP-Nk:cHl7r6kQO5E:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/MarcusWhitworth/~4/lFWZCYWP-Nk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.marcuswhitworth.com/2009/12/dynamic-linq-with-expression-trees/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<feedburner:origLink>http://www.marcuswhitworth.com/2009/12/dynamic-linq-with-expression-trees/</feedburner:origLink></item>
		<item>
		<title>Is Silverlight overtaking both Flex and AIR?</title>
		<link>http://feedproxy.google.com/~r/MarcusWhitworth/~3/VQiKxGrDvQw/</link>
		<comments>http://www.marcuswhitworth.com/2009/11/is-silverlight-overtaking-both-flex-and-air/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 19:53:05 +0000</pubDate>
		<dc:creator>Marcus</dc:creator>
				<category><![CDATA[Comparisons]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[silverlight]]></category>

		<guid isPermaLink="false">http://www.marcuswhitworth.com/?p=101</guid>
		<description><![CDATA[Reading the feature list of the upcoming Silverlight 4 release (now in beta), I am more than a bit impressed.  Up to now, there has been a few glaring features by which Silverlight was trailing behind Flex &#8211; camera/mic input; &#8230; <a href="http://www.marcuswhitworth.com/2009/11/is-silverlight-overtaking-both-flex-and-air/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>Reading <a href="http://timheuer.com/blog/archive/2009/11/18/whats-new-in-silverlight-4-complete-guide-new-features.aspx" target="_blank">the feature list</a> of the upcoming Silverlight 4 release (now in beta), I am more than a bit impressed.  Up to now, there has been a few glaring features by which Silverlight was trailing behind Flex &#8211; camera/mic input; printing; clipboard access; and right-to-left text being ones that spring to mind.  Admittedly, all of these are fairly niche features which most applications wouldn&#8217;t require.</p>
<p>Silverlight 4 not only brings in all these features, but also a pile of others.  Interestingly, they seem to be making a direct pitch against Adobe AIR with many of the features.  The new Elevated Trust Applications feature (for out-of-browser apps), enables a host of features typically reserved for desktop applications: <a href="http://timheuer.com/blog/archive/2009/11/18/whats-new-in-silverlight-4-complete-guide-new-features.aspx#localfiles" target="_blank">Local file access</a>; <a href="http://timheuer.com/blog/archive/2009/11/18/whats-new-in-silverlight-4-complete-guide-new-features.aspx#toast" target="_blank">Notifications API</a>; <a href="http://timheuer.com/blog/archive/2009/11/18/whats-new-in-silverlight-4-complete-guide-new-features.aspx#fullscreen" target="_blank">Full-screen full-keyboard access</a>; <a href="http://timheuer.com/blog/archive/2009/11/18/whats-new-in-silverlight-4-complete-guide-new-features.aspx#xdomain" target="_blank">Cross-domain policy-free networking</a>; and <a href="http://timheuer.com/blog/archive/2009/11/18/whats-new-in-silverlight-4-complete-guide-new-features.aspx#droptarget" target="_blank">Drop targets</a>.  Of course, features aside, the huge advantage of the Silverlight desktop approach over AIR is that there is only one runtime plugin required.</p>
<p>At the speed Microsoft is moving forward with Silverlight, Adobe is going to have to start seriously upping their commitment to the Flash platform if they want to stay at the top of the game.  Up to now, they could always give the argument of Flex being more feature-rich, and the ease of adaptation to the desktop with AIR &#8211; with both of these arguments now void, and Microsoft firmly remaining miles ahead in the developer tooling scene, Adobe&#8217;s work is cut out.  They still have greater marketplace penetration with Flash player, but that lead is only going to narrow also.</p>
<p>You&#8217;ve got to love competition!</p>
<div class="shr-publisher-101"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.marcuswhitworth.com%2F2009%2F11%2Fis-silverlight-overtaking-both-flex-and-air%2F' data-shr_title='Is+Silverlight+overtaking+both+Flex+and+AIR%3F'></a><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.marcuswhitworth.com%2F2009%2F11%2Fis-silverlight-overtaking-both-flex-and-air%2F' data-shr_title='Is+Silverlight+overtaking+both+Flex+and+AIR%3F'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic --><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/MarcusWhitworth?a=VQiKxGrDvQw:AM38r91CRwc:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/MarcusWhitworth?i=VQiKxGrDvQw:AM38r91CRwc:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/MarcusWhitworth/~4/VQiKxGrDvQw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.marcuswhitworth.com/2009/11/is-silverlight-overtaking-both-flex-and-air/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.marcuswhitworth.com/2009/11/is-silverlight-overtaking-both-flex-and-air/</feedburner:origLink></item>
		<item>
		<title>Silverlight tools for the Mac</title>
		<link>http://feedproxy.google.com/~r/MarcusWhitworth/~3/NTaHRTHKblM/</link>
		<comments>http://www.marcuswhitworth.com/2009/10/silverlight-tools-for-the-mac/#comments</comments>
		<pubDate>Thu, 29 Oct 2009 14:48:00 +0000</pubDate>
		<dc:creator>Marcus</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[silverlight]]></category>

		<guid isPermaLink="false">http://www.marcuswhitworth.com/?p=99</guid>
		<description><![CDATA[Just reading about the efforts to produce an Eclipse-based Silverlight development platform for the Mac &#8211; quite cool. I have to think though, perhaps the effort would have been better spent creating a port of Blend for the Mac&#8230; it &#8230; <a href="http://www.marcuswhitworth.com/2009/10/silverlight-tools-for-the-mac/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>Just reading about <a href="http://team.silverlight.net/announcement/eclipse-tools-for-silverlight-now-available/" target="_blank">the efforts to produce an Eclipse-based Silverlight development platform</a> for the Mac &#8211; quite cool.</p>
<p>I have to think though, perhaps the effort would have been better spent creating a port of Blend for the Mac&#8230; it seems to me that only a <em>tiny</em> minority of developers would opt for Eclipse over Visual Studio; whereas I&#8217;d guess nearly all designers <a href="http://forums.silverlight.net/forums/t/34817.aspx" target="_blank">would prefer to work natively</a> within MacOS.</p>
<p>I can kind of understand why they&#8217;ve done it, but I can only hope there&#8217;s another project underway with that Blend port&#8230;</p>
<div class="shr-publisher-99"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.marcuswhitworth.com%2F2009%2F10%2Fsilverlight-tools-for-the-mac%2F' data-shr_title='Silverlight+tools+for+the+Mac'></a><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.marcuswhitworth.com%2F2009%2F10%2Fsilverlight-tools-for-the-mac%2F' data-shr_title='Silverlight+tools+for+the+Mac'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic --><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/MarcusWhitworth?a=NTaHRTHKblM:lFv1W7AmnsY:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/MarcusWhitworth?i=NTaHRTHKblM:lFv1W7AmnsY:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/MarcusWhitworth/~4/NTaHRTHKblM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.marcuswhitworth.com/2009/10/silverlight-tools-for-the-mac/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.marcuswhitworth.com/2009/10/silverlight-tools-for-the-mac/</feedburner:origLink></item>
		<item>
		<title>ReSharper 5 – and I thought 4 was good</title>
		<link>http://feedproxy.google.com/~r/MarcusWhitworth/~3/qFiTRx4hvIs/</link>
		<comments>http://www.marcuswhitworth.com/2009/10/resharper-5-and-i-thought-4-was-good/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 12:12:27 +0000</pubDate>
		<dc:creator>Marcus</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://www.marcuswhitworth.com/?p=91</guid>
		<description><![CDATA[Reading this preliminary list of the upcoming features of ReSharper 5, it makes me wonder how any .NET developer could ever be without a tool like this.  Among the favorites would have to be Project Refactorings, and Call/Value Tracking.  Genius. &#8230; <a href="http://www.marcuswhitworth.com/2009/10/resharper-5-and-i-thought-4-was-good/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>Reading <a href="http://blogs.jetbrains.com/dotnet/2009/10/resharper-50-overview/" target="_blank">this preliminary list of the upcoming features</a> of ReSharper 5, it makes me wonder how any .NET developer could ever be without a tool like this.  Among the favorites would have to be Project Refactorings, and Call/Value Tracking.  Genius.</p>
<p>Having used the refactoring-and-<em>[insert feature here]</em>-anaemic <a href="http://www.adobe.com/products/flex/features/flex_builder/" target="_blank">Flex Builder 3</a> at length on a few recent projects, life just seems to get better and better in Visual Studio land.</p>
<div class="shr-publisher-91"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.marcuswhitworth.com%2F2009%2F10%2Fresharper-5-and-i-thought-4-was-good%2F' data-shr_title='ReSharper+5+-+and+I+thought+4+was+good'></a><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.marcuswhitworth.com%2F2009%2F10%2Fresharper-5-and-i-thought-4-was-good%2F' data-shr_title='ReSharper+5+-+and+I+thought+4+was+good'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic --><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/MarcusWhitworth?a=qFiTRx4hvIs:XzKOp3SG4Ys:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/MarcusWhitworth?i=qFiTRx4hvIs:XzKOp3SG4Ys:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/MarcusWhitworth/~4/qFiTRx4hvIs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.marcuswhitworth.com/2009/10/resharper-5-and-i-thought-4-was-good/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.marcuswhitworth.com/2009/10/resharper-5-and-i-thought-4-was-good/</feedburner:origLink></item>
		<item>
		<title>Creating a custom Silverlight 3 Smooth Streaming player</title>
		<link>http://feedproxy.google.com/~r/MarcusWhitworth/~3/N7hFxD0XvAc/</link>
		<comments>http://www.marcuswhitworth.com/2009/09/creating-a-custom-silverlight-3-smooth-streaming-player/#comments</comments>
		<pubDate>Thu, 24 Sep 2009 18:36:39 +0000</pubDate>
		<dc:creator>Marcus</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[silverlight]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://www.marcuswhitworth.com/?p=64</guid>
		<description><![CDATA[When it comes to video delivery, I come from a Flash background.  I&#8217;ve worked on numerous streaming video projects over the years, all of which were created with Flash &#38; Actionscript on the client side. Having been through the process &#8230; <a href="http://www.marcuswhitworth.com/2009/09/creating-a-custom-silverlight-3-smooth-streaming-player/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>When it comes to video delivery, I come from a Flash background.  I&#8217;ve worked on numerous streaming video projects over the years, all of which were created with Flash &amp; Actionscript on the client side. Having been through the process several times, I know all the hurdles I&#8217;m going to have to clear well in advance.</p>
<p>Documentation for coding a Silverlight 3 player against IIS Smooth Streaming is a little sparse.  IIS.net has several articles on the server setup, but I couldn&#8217;t find anywhere obvious regarding the client connection.</p>
<p>Unlike progressive video playback, you can&#8217;t just point the MediaElement.source at the video path then call play().  After a bit of searching, <a href="http://chris.59north.com/post/Playing-Smooth-Streaming-videos-in-Silverlight.aspx" target="_blank">most people were talking about</a> some <em>AdaptiveStreamingSource</em> class, which isn&#8217;t available in the base SL toolkit, but rather only found in <em>SmoothStreaming.dll</em> within the template players generated from Expression Encoder!</p>
<p>Per <a href="http://forums.silverlight.net/forums/t/121952.aspx" target="_blank">some handy forum posts</a>, the steps required are:</p>
<ol>
<li>With Expression Encoder installed, go to <em>C:\Program Files\Microsoft Expression\Encoder 3\Templates\en</em>, select any template, and copy the SmoothStreaming.xap file.</li>
<li>Rename your copied .xap file to .zip, unzip, and take out the <em>SmoothStreaming.dll</em> and <em>PlugInMssCtrl.dll</em> files.</li>
<li>Reference these assemblies in your project, and you can then start using <em>AdaptiveStreamingSource.</em></li>
</ol>
<p>So, once you can finally access the required assemblies, you can then invoke your IIS Smooth Streaming service with something along the lines of the following:</p>
<pre class="brush:csharp">var mediaPath = "testClip_h1080p.ism/manifest";
var source = new AdaptiveStreamingSource
{
   ManifestUrl = new Uri(mediaPath, UriKind.RelativeOrAbsolute),
   MediaElement = streamElement // the xaml MediaElement
};
source.StartPlayback();</pre>
<p>Make sure you put the trailing &#8216;/manifest&#8217; after your stream path.</p>
<p>Simple enough, once you&#8217;ve figured out the basics!  Not exactly sure what MS were thinking by not including the SmoothStreaming assemblies in the SL3 toolkit?  Surely they realise not everyone wants to use a templated player.  Or have I missed something here?</p>
<div class="shr-publisher-64"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.marcuswhitworth.com%2F2009%2F09%2Fcreating-a-custom-silverlight-3-smooth-streaming-player%2F' data-shr_title='Creating+a+custom+Silverlight+3+Smooth+Streaming+player'></a><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.marcuswhitworth.com%2F2009%2F09%2Fcreating-a-custom-silverlight-3-smooth-streaming-player%2F' data-shr_title='Creating+a+custom+Silverlight+3+Smooth+Streaming+player'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic --><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/MarcusWhitworth?a=N7hFxD0XvAc:Y4yi0cXDYRg:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/MarcusWhitworth?i=N7hFxD0XvAc:Y4yi0cXDYRg:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/MarcusWhitworth/~4/N7hFxD0XvAc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.marcuswhitworth.com/2009/09/creating-a-custom-silverlight-3-smooth-streaming-player/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.marcuswhitworth.com/2009/09/creating-a-custom-silverlight-3-smooth-streaming-player/</feedburner:origLink></item>
	</channel>
</rss><!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching using disk: basic
Object Caching 1519/1546 objects using disk: basic

Served from: www.marcuswhitworth.com @ 2012-02-03 12:53:05 -->

