Code Snippets for Windows Store Apps

Posted September 11, 2012 10:37 AM Categories: Windows 8 | Channel 9 | C# | C/C++ | Visual Basic | JavaScript

Code Snippets for Windows Store AppsIf you're writing (or plan to write) a Windows Store app, check out our Windows Store App snippets project!  In partnership with the Visual Studio team, we have created a collection of around 60 IntelliSense Code Snippets for common Windows Store app programming tasks. The snippets are available for Visual Basic, C#, C++, and JavaScript developers.

For more details, please see:

With the Windows Store now open for submissions, use these snippets to get a jump start on your project.

After installing, just right-click and select Insert Snippet, and select the snippet from the list. Then press Tab to jump between fields.  Here's an example:


Give them a try and let us know what you think!

Pinball 2000 Software Update with Windows 7 x64

Posted August 24, 2012 9:20 AM Categories: Gaming | General | Hardware | Pinball

Warning: pb2kThis is a pretty off-topic post about pinball, but maybe it'll help someone searching for the information.

Backstory: My dad was a coin-op operator.  I'm the son of a coin-op operator.  As you might imagine, I have a just a tiny bit of love for video games and pinballs.  When my dad passed away in 2008, I decided to keep my favorite pins from the route:  Funhouse, Addams Family, Theatre of Magic, Tales of the Arabian Nights, and Revenge from Mars.

After sitting in storage for a couple of years, the software update sitting on Revenge from Mars would no longer checksum properly.  The game was running fine, but obviously something was wrong.  After lots of other work on the machine, it was time to update the firmware again to version 1.5.

Finding the software and ROM images was easy.  Everything is available at  Anyone can just grab the Pinball 2000 Update Manager and the appropriate software update for the machine to be updated.  However, trying to install and run the Pinball 2000 Update Manager was a different story.  The installer choked when running on my Windows 7 x64 machine.  Not surprising since this application and installer was written 13 years ago.  Luckily, I was able to install the app in a Windows XP x86 virtual machine and copy the installed files over to my laptop.

Unfortunately, this didn't immediately get me much further since the GUI updater requires some OCX files to be registered, and that's a circle of hell I didn't want to enter.  Exploring a bit further, I found the fupdate.exe command line application that actually does the flashing.  The Pinball 2000 Update Manager is just a pretty GUI wrapper.  Even more interesting, the source code for the fupdate.exe is included in the package.  It's a win32 command line app compiled against a very old version of Cygwin.  I have ripped out the important files into a separate archive.  If you're just interested in updating a Pinball 2000 machine from a modern computer and OS, you can download fupdate here.

Running this command line tool on the Windows 7 x64 laptop worked just fine.  Here's the command line to start the update process:

fupdate -p\pin2000_50070_0150_07252000_B_10000000\50070 -fpin2000_50070_0150_ COM1
  • The –p switch denotes where the software update files are.
  • The –f switch specifies a file prefix for each file in the update.  For Revenge from Mars, every ROM image is prefaced with the above string.
  • The command's final switch is the COM port to use for the update.

The USB to serial adapter I used on my laptop installed itself as COM17.  Trying to run the above command with the COM17 switch failed.  I was able to go into the properties of the COM adapter and force it on to COM1 which worked just fine.  You can do this by going into Device Manager, right-clicking on the port you're using and selecting Properties.  In the dialog that pops up, hit the Advanced button on the Port Settings tab, then select a new COM port from the drop-down as shown:


When you run the above fupdate.exe program, the update process runs, and you should see output in the console window as shown, along with a progress bar on the pinball's monitor:

bootdata.rom:    0 blocks of   64 (   0) sent, total bytes remaining 4980724
im_flsh0.rom:    0 blocks of 1201 (  64) sent, total bytes remaining 4947956
im_flsh0.rom:   64 blocks of 1201 ( 128) sent, total bytes remaining 4915188


      sf.rom: 1920 blocks of 2048 (9600) sent, total bytes remaining 65536
      sf.rom: 1984 blocks of 2048 (9664) sent, total bytes remaining 32768
************: 9728 blocks of 9728 (9728) sent, total bytes remaining 0
Update complete - total blocks 9728 (4980724 bytes)

That's it!  Once the update completes (about 15-20 minutes in my setup), the newly flashed software will be verified, and the pinball is ready to be played!

Visual Studio Live! - Redmond

Posted July 11, 2012 8:50 AM Categories: Async | C# | VSLive Redmond | Events

imageI will be presenting a session at Visual Studio Live! in New York this August 6-10 hosted on the Microsoft Campus.  The conference is a full 5 day event and there’s still time to register!

T13 - Writing Asynchronous Code Using .NET 4.5 and C# 5.0
Date: Tuesday, August 7, 2012
Time: 2:30 PM – 3:45 PM 
Level: Introductory

A variety of new features were added to the .NET 4.5 Framework, including support for easily writing asynchronous code. This session will introduce the concepts of asynchronous programming, .NET Tasks, how to ensure your UI remains responsive, and how to do all of this properly in your own applications using the new async and await keywords. If you’re looking for ways to provide a better, smoother experience for your users, don’t miss this session!

Get more information on the conference at:

Hope to see you all there!

TechEd North America 2012

Posted June 7, 2012 8:42 AM Categories: Coding4Fun | Events | Kinect | TechEd'm off to TechEd North America later this week where we'll be showing off the Project Detroit car and our BoxingBots project previously demonstrated at SXSW in March. 

09615539-1a33-49f7-b438-ca1b9543d712 IMG_0296[5] 

Dan Fernandez and I will also be giving a talk on Kinect goodness.  Here are the details:

Coding4Fun: Build Fun, Cool, Commercial Applications Using the Kinect for Windows SDK

Session Code: DEV330
Speaker(s): Brian Peek, Dan Fernandez
Tuesday, June 12 at 5:00 PM - 6:15 PM in S320A

Come to this must-see session to find out how you can use the Kinect for Windows SDK to build commercial applications! Learn how the RGB and depth cameras work, how to use and fine-tune skeletal tracking, how to read an audio stream from the Kinect microphone array and even how to send Kinect data over the network including to your Windows Phone

This same session will be given at TechEd Europe in two weeks, with Clint Rutkas playing the part of me.  I will not be at the Europe conference.

So, if you're attending either TechEd this year, please stop by the Coding4Fun areas or our session and say hello!

Assembla SVN With Local Backup

Posted May 22, 2012 9:32 AM Categories: Source Control | SVN | Tips & Tricks

I recently moved my personal source control setup from a local SourceGear Vault server to a free, hosted SVN service from Assembla.  I wanted to have access to my source code while travelling without having to keep the server running at home, and Assembla provides users with up to 1GB of space and unlimited users absolutely free for private SVN hosting.

I wasn't looking to import my entire Vault database over to SVN, so manually creating new projects in Assembla was just fine.  I setup 3 different repositories:  one for personal projects, one for code related to sessions I give, and one scratch space that I can use to test things out and delete without issue.

My main concern in going to a hosted solution is ensuring I have a current backup of my repositories should something go wrong.  Assembla provides a manual backup option via their website, but I wanted something automated.  After some searching, I learned of the svncync command.  This command allows you to mirror a SVN repository from one machine to another.  Using this I was able to come up with a pretty automated solution that should work to sync up any two SVN repositories.

Preparing VisualSVN

I created the same three repositories described above on a local machine running VisualSVN that is backed up nightly via Windows Home Server.  VisualSVN  needs to have a specific hook set up with no content in order for svnsync to work.  To do this, right-click on the repository, and select All Tasks –> Manage Hooks.

5-21-2012 3-29-14 PM

On the Hooks tab, select the Pre-revision property change hook and click Edit.

 5-21-2012 3-30-54 PM

In the dialog that pops up, just click OK, and then click OK on the previous dialog.

5-21-2012 3-31-10 PM

This process creates an empty file named pre-revprop-change.cmd in the repository's hooks directory.

Setup Sync

To setup sync between the local VisualSVN server and remote repository, the local repository needs to be configured for sync.  To do this, run the following command, replacing the repository names and locations:

svnsync init file:///c:/repositories/myrepository/

With VisualSVN setup, we can pull in the current state of the remote repository as follows:

svnsync sync file:///c:/repositories/myrepository

Set the UUID

Andy Pook mentioned this tidbit in the comments below.  If you want to be able to seamlessly switch between the main and synced repositories, the UUIDs of each repository need to be the same.  This can be accomplished pretty easily.  First, get the UUID of the remote repository using the svn info command:

svn info

The output will contain a line that looks like this:

Repository UUID: 48c27914-95eb-48c8-b9f6-abc9d842ae0f

That's the UUID of the remote repository.  To set it to the synced repository, use the svnadmin setuuid command:

svnadmin setuuid c:\repositories\myrepository 48c27914-95eb-48c8-b9f6-abc9d842ae0f

Of course, change the names, locations, and UUID to reflect your configuration.  With this set up, you can now switch to the synced repository on the fly should something happen to the remote setup.

Automating the Backup

To automate this, I created a simple batch file that uses the svnsync command and runs nightly as a scheduled task to sync all three repositories with the local SVN server.  Here's what the batch file looks like:

"C:\Program Files (x86)\VisualSVN Server\bin\svnsync" sync file:///c:/repositories/Sessions
"C:\Program Files (x86)\VisualSVN Server\bin\svnsync" sync file:///c:/repositories/Personal
"C:\Program Files (x86)\VisualSVN Server\bin\svnsync" sync file:///c:/repositories/Scratch

I now have nightly backups of my hosted SVN repositories with very little effort.  This might be one of those things that everybody knows, but it's new to me. Enjoy!