In C# Passing Delegate As Parameter, Then Executing on Return

I did not know that it is possible to have a delegate as a call to a method, then have that method actually execute that delegate at it’s convenience.  I’m busy converting a Xamarin conference application for the IPad and am wrangling getting it to show Silicon Valley Code Camp data rather than MWC (Mobile World Conference data). So, here is the method I ran into: var siteParser = new MWC.SAL.MWCSiteParser(); siteParser.GetConference (Constants.ConferenceDataUrl, () => { var c = siteParser.ConferenceData; if (c == null) { … Continue Reading

Building a Login Screen With Xamarin’s MonoTouch and XCode StoryBoard


  Part 1 The Video and Introduction (this) Part 2 In Blog Format with words and screen shots     Introduction I’ve been hard at work learning the MonoTouch framework from Xamarin recently.  For those that don’t know, MonoTouch is a framework that runs on top of the Apple XCode development environment that allows you to essentially use the .net framework as your programming language of choice instead of objective C (I hope I got that right).  Since it has been a while since I’ve used C, and I have so much stuff I’ve done in C# I can leverage, this seems like a good fit. I’m about a good solid week of programming into this and I have to admit I’ve gotten pretty … Continue Reading

Deeply Nested Null Checking in C# verses Assert with no nesting

One of the code smells that particularly bothers me (though I often find myself doing it anyhow) is when I defensively program against nulls in C# (though could be any other language).  That is, I do something like the following var rec = getRecord(..); if (rec != null) { var rec1 = getAnotherRecord(..); if (rec1 != null) { rec2 = getAThridRecord(..); if (rec2 != null)... The code gets ugly quick and the nesting does not help the readability, and if anything, hurts it. Today, while using a daily build of Resharper7, I noticed that when I asked resharper to do the null check for me, instead of doing the above, it did the following: var rec = getRecord(..); Debug.Assert(rec != null,"rec != … Continue Reading

Building a Simple Window Service Application in Visual Studio 2010 That Runs, Sleeps and Stops


Introduction The goal is to create a simple Service in Windows 7 (or other similar OS’s) with Visual Studio 2010 that simply starts, sleeps for 15 seconds, then stops.  I realize this is not that useful, but basically, it covers the case of building a service that actually does something and when finished stops.  In my personal case, my thread has a while(true) loop which keeps looking for new work and only completes when certain conditions are met (like a fatal error that is non recoverable). Microsoft has given us a pretty good set of docs and walk through.  You can find them all here:   The Steps Create a new Visual Studio Project of type “Windows … Continue Reading


Get every new post delivered to your Inbox

Join other followers: