Tech in the 603, The Granite State Hacker

Locking Resources in C# for Read/Write Concurrency

In a previous project, I became a big fan of System.Threading.ReaderWriterLockSlim.  It was an excellent way to guard a resource against concurrency in a relatively flexible manner.  

C# has a lock(object) {} syntax for simple concurrency locks, but what if you have a resource that can sometimes be used concurrently, and other times, exclusively?

Enter System.Threading.ReaderWriterLockSlim.  This has a few handy methods on it for guarding code on a non-exclusive (Read) and exclusive (Write) mode, with an upgradeable lock, as well, so you don’t have to release a read lock in order to upgrade it.

This source works just as well in .NET as UWP.

I commented the code enough to try to make it so that someone familiar with ReaderWriterLockSlim and using(IDisposable){} would understand the rest, so without further ado…

https://gist.github.com/GraniteStateHacker/e608eecce2cb3dba0dbf4363b00e941f.js

Tech in the 603, The Granite State Hacker

No Kid Hungry, Resolution To Renew My Commitment

It’s New Years Day, 2013. 

My kids made a comment, this morning, about how commercials on the TV were the same today as they were yesterday.  Without thinking about it, I flatly told them that it doesn’t really work that way; that today isn’t really much different from yesterday. 

I realized right away, even without my wife’s reproving look, that I’d blundered a bit as a dad just then.  I remember being disappointed when I was a kid by how things failed to change over night between New Years Eve & New Years Day.  I had to explain to my kids that the real difference between 2012 and 2013 was not the messages in TV commercials, but what they, themselves, resolved to change…. and the work they put into making that happen.

That, of course, got me thinking about my resolutions for 2013..  I’d tweeted a couple cute ones last night, on New Years Eve…  but there’s one that I’ve been thinking about for a while now that I’ve only hinted at otherwise.

In 2012, I saw how much deeper problems seem to be running, economically….  how even some of my extended family would consider my immediate family’s lackluster financial situation to be a blessing compared to what they’re facing. 

Media news reports that the economy is improving.  That may be true on Wall Street, but it seems hollow on Main Street.  Indeed, the so-called improvements of 2012 feel like they’ve come at the expense of folks who have been on the brink of needing help.  Clearly trickle down economics have failed.  News of improvement only means that people are slower to give… because we’re not in such financial distress, anymore…  right?  Well… worse, with fiscal cliffs and inflation factors threatening to take hold in 2013, who can give?   Sadly, trickle up poverty seems to be in full effect.  

In the meantime, one thing that didn’t work out the way I’d hoped in 2012, was the results from my charity project. 

As a product, I’m very pleased with what I was able to publish in my spare time.  It’s an honest to goodness Sudoku puzzle game for Windows Phone…  no spyware, no malware, no ads, no personal information used or transmitted…   just the kind of game I wanted to play, and something I wanted to share.   I built it using tools that I wanted to work with.  I published it globally for free, and also for the U.S. for $5 with my own personal commitment to donate all proceeds to charity.  (Folks in the U.S. have a choice…  there’s no difference between the free and the paid editions of the app… it’s just if you want to donate to charity or not.)

As a tool for charity to raise funds and/or awareness…  well…  I’m hoping to change it’s past performance.  I understand that it looks bad that I can’t market the app with official cause logos & such from the charity I’ve committed to support…  I asked for permission for that, and for legitimate reasons, I couldn’t.  My hope was that the app would earn the privilege by the contributions it generated.  It’s been tempting to shoot first and apologize later, but in a world of “no good deed goes unpunished”, I didn’t want to take risks I couldn’t back up.

After an experimental social media campaign that mostly just annoyed friends & family on Facebook, I gave up.  There was too much real work that needed my attention.  I couldn’t let an effort that was getting nowhere cause me to fail at stuff like my job.  

I’ve decided to renew my efforts with the hope that it gains some traction at some point… I’m not fighting for the product; I have nothing to prove there. 

It’s the cause.  Helping hungry kids. 

I have yet to figure out exactly what this means… I don’t want to annoy friends & family… but the cause needs hands.

Even if you have no interest in my charity project as a fundraiser, please seriously consider contributing to the cause. Even if you can’t do that…  please help spread the word. 

This is their website:
No Kid Hungry

Tech in the 603, The Granite State Hacker

GSSPUG Hub (Free App) for Windows Phone Now Available

My “artisan portfolio” of Windows Phone apps just DOUBLED in size!  Yes, I’ve now successfully published my second Windows Phone app.  🙂

The Granite State SharePoint Users Group Hub is a somewhat minimal app, but if you’re a member of the group, it’s got some useful features.   My favorites are being able to get info about the next meeting, (both in the app, and as a live tile) and being able to RSVP through EventBright.

The direct link to find it in the Marketplace on your Windows Phone is this.

Regarding the name…  GSSPUG?  Ya, I know… it’s not quite as intuitive as NHSPUG…    

If you’re from New Hampshire, you know you search for “Granite State” any time you’re looking for something local…  and if you don’t know that, it probably is just as well you don’t find it.  😉

One other nice thing is that the content is largely driven from the group’s web site, which, of course, is a SharePoint site.   The app does require a network connection, but it can be updated without having to go through the week-long process of publishing an update. 

Like Jimmy Sudoku, the app uses your phone’s system wide theme colors.

Essentially this is what ends up in the Hub app.

And it appears like so:

Tech in the 603, The Granite State Hacker

Project to Help Feed Starved Kids – Jimmy Sudoku v4

UPDATE Feb 6, 2014:  http://granitestatehacker.kataire.com/2014/02/jimmy-sudoku-5-orange-edition.html

Click here to view in the Windows Phone App Marketplace.  (the app is ‘free’ with the $5 donation via purchase.  All proceeds go to #NoKidHungry.)

I’ve had a lot of fun learning the quirks of Silverlight for WP7 devices, and after playing with some of the other WP7 Sudoku’s out there, I’m very glad to have Sudoku done my way on my phone again. 🙂  I’m even more psyched that I can share my app with others, as it’s now Certified by Microsoft and available on the Windows Phone App Marketplace!

I have to admit… there’s a lot of competition out there for Sudoku’s on WP7 devices, and probably not a huge demand… I realize that for as much fun as I had polishing this app,  probably the best way to find its value is to “give it away”.  

Scan this Tag with your Windows Phone to find Jimmy Sudoku
Scan this Tag
with your phone to find
Jimmy Sudoku
in the
Windows Phone
App Marketplace

So my family & I considered some options and decided on a national organization that helps feed under-fed/malnourished children here in the US. I thought it was a fitting thing… building software is my strength, and this is a way I can share it.   I also can think back to some exceptionally lean times when I was a kid… memories I’d love to help avert for others if any way possible.  So, yes, all proceeds from paid downloads will be donated to that cause.

I finally had a chance to re-do the old .NET 2.5 Compact Framework-based app as a Silverlight 4 app for Windows Phone. I’ve been toying with this release for months (since November 2011, actually… I pulled down Visual Studio Express 2010 for Windows Phones around then, anyway).  

In case you’re wondering… I asked the charity if it was ok to use their name and maybe a logo or something, but out of respect for their other national-market beneficiaries who have already done this, I would have to also guarantee a sizable donation.  100% is the best I can do, but that’s not necessarily a sizable donation, so I can’t use any trademarked IP, which, as I understand it, includes their name.  (I’m glad I asked.  🙂    While I can’t do this now, I’m hoping that if I play by the rules and manage to make a decent contribution with it, that I’ll earn the privilege and kick the project up a notch.  (In the meantime, I wonder if the twitter hashtag #NoKidHungry counts…. )

You can also click here on just about any device to get to the Marketplace site.


Finally, please visit the Facebook Page, and feel free to Like and/or Share posts to help spread the word!  🙂

Anything you can do to help is appreciated!

Tech in the 603, The Granite State Hacker

Compact and Full .NET Frameworks

One of the things I’ve been intrigued by for a while now is the fact that code compiled for the .NET Compact Framework (all versions) executes very nicely on the full .NET Framework.

For example, my personal hobby project, “Jimmy Sudoku”, is written in C# for the .NET Compact Framework 2.0. There are actually two install kits. The first is a .CAB file for Windows Mobile devices. The second is an .MSI for Windows 9x, XP, and Vista. The desktop install kit even serves two purposes. First, it installs the program on the desktop. Second, it leverages ActiveSync to push the .CAB up to the Windows Mobile device.

It’s a .NET Compact Framework app especially for Windows Mobile devices, but many ‘Jimmy’ fans don’t have a Windows Mobile device to run it on.

The coolest part is the ease in which all of the components inter-operate. The .EXE and .DLL’s that are delivered to the mobile device are the very same as the ones that are delivered to the desktop. Like Silverlight to WPF, the Compact Framework is a compatible subset of the full framework, so interoperability is a given.

Even better, you can reference CF assemblies in Full framework assemblies. One immediate offshoot of this in my hobby project… the web service I built to service “Game of the Day” requests actually references the CF assembly that implements the game state model and game generator code. The assembly that generates games on Windows Mobile PDA’s & cell phones is the very same assembly that generates games in the ASP.NET web service.

Admittedly, there are some bothersome differences between the CF and the Full .NET Framework. The CF does not support WPF. The CF has no facilities for printing. Also, while the CF does supports some of the common Windows Forms dialogs, it does not support File Save and File Open dialogs on Windows Mobile Standard Edition (Smart Phone / non-touchscreen) devices.

These differences can be overlooked to some extent, though, for the fact that one compiled assembly can execute on so many very different machine types. Further, with interoperability, one can extend a CF-based core code with full-framework support. For example, I’m currently playing with desktop print functionality for my hobby project.

Something that I’d really love to see, some day, is a good excuse to develop a Windows Forms app for a client that had shared components between the desktop and a mobile.

I can imagine that this model would be superb for a huge variety of applications, allowing a fully featured UI for the desktop version, and an excellent, 100% compatible, very low risk (almost “free”) portable version.

I’ve often thought this would work great for apps that interface hardware, like:
field equipment,
mobile equipment,
vehicles of all sorts,

…simply plug in your PDA (via USB or Bluetooth), and it becomes a smart management device for the equipment, using the very same code that also runs on the desktop.