Steel City Codefest 2014 – The Checkpoint

Finally getting around to posting about my experience at this year’s Steel City Codefest where I worked with a team of my colleagues to whip up a prototype of an app for a non-profit organization: TheCheckpoint.org.

THE PROJECT

This particular project was to create a mobile app (cross-platform) for veterans to locate and review/rate resources and services. While this doesn’t sound like a particularly flashy application to work on, we felt it was one with more need than the others (plenty of teams volunteering for other projects) and the challenge was really to try to make something useful and interesting.

THE TEAM AND THE TECH

Initially I had no plans to participate in Codefest but a few of my colleagues at work were joining in so I figured I would give it a shot.  We all have many years of experience working on a variety of technologies but we all shared a common background for C#/.NET so we decided to leverage Xamarin’s cross-platform native app framework so that we could all contribute as equally as possible.  Since we were targeting both iPhone and Android we felt that we were too limited by a hybrid-mobile solution and didn’t have a big enough team to go full native (Objective-C and Java) so Xamarin fit right in the middle.

Additionally, we wanted to share as much code as possible (really the only way to recoup the cost of tools/platforms like Xamarin) so we decided to incorporate MvvmCross, a framework for Xamarin allowing us to only need to re-write the view layer and share all the way down through the ViewModels and so on.

THE PROCESS

While we had done some initial planning after work, we pretty much came in with a blank slate ready to get started.  As I was the only one with a MacBook, I was on the hook for ripping out the iPhone version, Geoff had some Android experience so he was tackling that, Mark started working through integration with FourSquare, and since our designer was a no-show, Steve got stuck with the UX/UI design work and also kicking in on the ViewModels.

15 straight hours of coding later and out pops a prototype of an app:

20140224_142409000_iOS 20140224_142417000_iOS 20140224_142421000_iOS

WHAT’S NEXT

I am planning on finishing this app as soon as I get a chance to get working on it.  To help, I am working with Jared from Checkpoint to apply for some grant money to cover the cost of licenses (Xamarin), services (some mobile backend-as-a-service) and some time/help/kindness of others!

Thread.Sleep (asynchronously) in a Windows Store App (WinRT)

UPDATE:  Another option is to use await Task.Delay(ms) which would require you to be in an async method (which my examples are).

I thought I had a simple idea that would require simple code: In my “service mock” class I wanted to sleep the thread for 2 seconds to simulate a real web service call to see how my UI reacted.

Simple, right? Just throw a good-ol’ Thread.Sleep() in there and all is well? Nope!

Issue #1 – System.Threading.Thread is no more …
Luckily, a quick Internet search (I refuse to turn the name of my search engine into a verb) revealed a “hack” to sleep on a thread:

new System.Threading.ManualResetEvent(false).WaitOne(ms);

Issue#2 – But it blocks my thread.
Ok … but this blocks my thread and C# 5 gives me a nice async/await pattern so as not to block my thread and MRE is not awaitable.  Ok … I’ll just spawn off a task and sleep on it.

await Task.Run(() => { new System.Threading.ManualResetEvent(false).WaitOne(2000); });

Or use Task.Delay inside an async lamba or method:

await Task.Delay(2000);

There you have it.  I can now simulate a slow web service call in my stub/mock service implemenation.

Post a comment if there is a better way to do it or just to contemplate the deep meaning of  “Sleep asynchronously.”