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

UWP Equivalent for HttpUtility.ParseQueryString

Getting ready for my LUIS presentation at the Granite State Windows 10 Platform Devs Users Group (@WPDevNH), it made sense to demo LUIS using UWP rather than .NET classic.  (Join us, 11/16 at the Microsoft Store in Salem, NH…  https://www.meetup.com/Granite-State-NH-WPDev/events/243099117/ )

For a demo related to LUIS querying, I needed an alternative to System.Web.HttpUtility.ParseQueryString.  (based on this demo:  https://docs.microsoft.com/en-us/azure/cognitive-services/LUIS/luis-get-started-cs-get-intent )

I did a simple decorator of a Dictionary, adding a constructor to parse using WwwFormUrlDecoder, and overriding the ToString() to put it back together…

I whipped one up relatively quickly, but decided this would be a decent quick post.  Here’s my alt code:

usingSystem.Collections;
usingSystem.Collections.Generic;
using System.Net;
using System.Text;
usingWindows.Foundation;
namespaceLUIS_Examples
{
    public class ParseQueryString : IDictionary<string, string>
    {
        private IDictionary<string, string> _internalDictionary = new Dictionary<string, string>();
        public ParseQueryString(string queryString) :
            base()
        {
            var decoder = new WwwFormUrlDecoder(queryString);
            foreach (var item in decoder)
            {
                _internalDictionary.Add(item.Name, item.Value);
            }
        }
        public override string ToString()
        {
            var sb = new StringBuilder();
            foreach (var aPair in _internalDictionary)
            {
                sb.AppendFormat(“{0}={1}”, WebUtility.UrlEncode(aPair.Key), WebUtility.UrlEncode(aPair.Value));
            }
            return sb.ToString();
        }
        public string this[string key] { get => _internalDictionary[key]; set { _internalDictionary[key] = value; } }
        public ICollection<string> Keys => _internalDictionary.Keys;
        public ICollection<string> Values => _internalDictionary.Values;
        public int Count => _internalDictionary.Count;
        public bool IsReadOnly => _internalDictionary.IsReadOnly;
        public void Add(string key, string value)
        {
            _internalDictionary.Add(key, value);
        }
        public void Add(KeyValuePair<string, string> item)
        {
            _internalDictionary.Add(item);
        }
        public void Clear()
        {
            _internalDictionary.Clear();
        }
        public bool Contains(KeyValuePair<string, string> item)
        {
            return _internalDictionary.Contains(item);
        }
        public bool ContainsKey(string key)
        {
            return _internalDictionary.ContainsKey(key);
        }
        public void CopyTo(KeyValuePair<string, string>[] array, int arrayIndex)
        {
            _internalDictionary.CopyTo(array, arrayIndex);
        }
        public IEnumeratorstring, string>> GetEnumerator()
        {
            return _internalDictionary.GetEnumerator();
        }
        public bool Remove(string key)
        {
            return _internalDictionary.Remove(key);
        }
        public bool Remove(KeyValuePair<string, string> item)
        {
            return _internalDictionary.Remove(item);
        }
        public bool TryGetValue(string key, out string value)
        {
            return _internalDictionary.TryGetValue(key, out value);
        }
        IEnumerator IEnumerable.GetEnumerator()
        {
            return ((IEnumerable)_internalDictionary).GetEnumerator();
        }
    }
}

Tech in the 603, The Granite State Hacker

Rise of the Smart App

Microsoft didn’t talk much about the Windows Phone at Build 2016.  If you think that’s news, you’re missing the point.

As Microsoft re-defines “Mobile First, Cloud First” they declare shenanigans on the idea that the tech world revolves around phone and tablet.  Yes, tablet and smartphone are mature, first-class citizens, now, but they’re not above laptops, PCs, or other computing devices, as Apple (and perhaps even Samsung) might have you believe.

There’s no denying that Microsoft lost the battle for smartphone market share.  RIM’s Blackberry, considered a relic of the primordial smartphone market, is all but forgotten. Microsoft was pushing Windows Phone as significant competitor, yet, with about the same market share as Blackberry, no one really took their smartphone offering seriously. 

Until Windows Phone’s recent convergence with the PC on the universal Windows 10 OS, Windows Phone had no more competitive edge than Blackberry, either.  Sadly, this new competitive edge comes too little, too late. Or has it?

Several years ago, in a very sly move, Apple narrowed and laser-focused the global technology mindset on a much smaller battle… one that it was well positioned in. Apple then equated the battle to the war… They made it all about the smartphone/tablet market.  (I don’t think Apple counted on Android, but it didn’t matter… in terms of market share, Android won, but in terms of profitability, Apple won.)  Billions of dollars can’t be wrong, so Microsoft tried to position itself in Apple’s vision, and let itself get dragged around for years… 

Until now.

By connecting Mobility with Portability, Microsoft is driving the scope of technology mindshare again, and are driving it back out to a scale Apple will have to struggle to position itself in. Apple made good smartphones.  Cool beans.

With its converged “Universal” Windows 10 platform, Xamarin portability, and mature cloud offerings replete with machine learning, Microsoft is targeting a much broader “smart app” market… Smart Apps are apps that make any device (keyboard, mouse, display/touchscreen, microphone, pen, scanner, camera, video recorder/editor, audio mixer, cell phone, media player, whiteboard, virtual/augmented reality, what have you) into a smart device.  (Notice anything missing here?  perhaps cars…  but it’s hard to imagine that won’t change in the next few years…  after all, cars (e.g. BMW) did get mentioned at Build.) 

The smartphone isn’t irrelevant, it’s just not the whole pie. The reality is that Microsoft is not going to exclude phones from Windows 10 now or any time soon. 

Smartphone prominence is not innovation superiority.

So, how does this make you feel?

Tech in the 603, The Granite State Hacker

Live Process Migration

For years now, I’ve been watching Microsoft Windows evolve.  From a bit of a distance I’ve been watching the bigger picture unfold, and a number of details have led me to speculate on a particular feature that I think could be the next big thing in technology….   Live process migration.  

This is not the first time I’ve mused about the possibility… [A big feature I’d love to see in Windows 11] it’s just that as I work with tools across the spectrum of Microsoft’s tool chest, I’ve realized there are a few pieces I hadn’t really connected before, but they’re definitely a part of it.

What is live process migration?  Folks who work with virtual machines on a regular basis are often familiar with a fancy feature / operation known as live virtual machine migration….  VMWare’s vSphere product refers to the capability as vMotion.  It’s the ability to re-target a virtual machine instance, while it’s running… to move it from one host to another.

In sci-fi pseudo psycho-babble meta physio-medical terms, this might be akin to transitioning a person’s consciousness from one body to another, while they’re awake…  kinda wild stuff.

As you can imagine, live VM migration is a heavy duty operation… the guest machine must stay in sync across two host computers during the transition in order to seamlessly operate. For the average user, it’s hard to imagine practical applications. 

That said, live process migration is no small feat either.  A lot of things have to be put in place in order for it to work… but the practical applications are much easier to spot. 

Imagine watching a movie on Netflix on your Xbox (or maybe even your Hololens), but it’s time to roll.   No problem, with a simple flick gesture, and without missing a beat, the running Netflix app transitions to your tablet (or your phone), and you’re off.   Then you get to your vehicle, and your vehicle has a smart technology based media system in it that your tablet hands off the process to.   It could work for any process, but live streaming media is an easy scenario.

From a technical perspective, there’s a bunch of things required to make this work, especially across whole different classes of hardware…  but these problems are rapidly being solved by the universal nature of Windows 10 and Azure.

Commonality required:

  • Global Identity (e.g. Windows Live)
  • Centralized Application Configuration
    • Windows 10 apps natively and seamlessly store configuration data in the cloud
  • Binary compatibility
    • Universal apps are one deployable package that runs on everything from embedded devices to large desktops and everything in between.
  • Inter-nodal process synchronization
    • Nothing exemplifies this better than the 1st class remote debugging operation  in Visual Studio.  You can run an app on a phone or device from your laptop, hit breakpoints, and manipulate runtime state (local variables) from the laptop and watch the device react in real time.
  • Handoff protocol
    • I’m sure it exists, but I don’t have a good word to describe this, but it’s probably based on something like SIP
  • Runtime device capability checking (the part that sparked this blog post).
Over the years, there have been a lot of “write once, run anywhere” coding schemes.  Most involve writing a program and having the compiler sort out what works on each type of hardware…. what you get is a different flavor of the program for different kinds of hardware.  In Windows 10, it’s different.  In Windows 10, the developer codes for different device capabilities, and the application checks for the required hardware at run time.  
While the UWP does an amazing job of abstracting away the details, it puts some burden on the hardware at runtime…  the app developer has to write code to check, anyway: hey, is there a hardware camera shutter button in this machine?  If yes, don’t put a soft camera shutter button on the screen, but now the app has to check the hardware every time it runs.
I struggled a bit trying to understand this latter point…  why would Microsoft want it to work that way?  Except for a few plug & play scenarios, it could be optimized away at application install time…  unless your process can move to a different host computer/phone/console/tablet/VR gear.
While I am (more recently) a Microsoft V/TSP working for BlueMetal, an Insight company, I have no inside information on this topic.  I’m just looking at what’s on the table right now.   We’re almost there already.  Yesterday, I showed my son how to save a document to OneDrive, and within moments, pick up his Windows 10 phone and start editing the same document on it.
In my mind, there’s little doubt that Microsoft has been working its way up to this since Windows Phone 7… the only question in my mind is how many of these tri-annual Windows 10 updates will it be before “App-V Motion”-style live process migration is a practical reality.
Tech in the 603, The Granite State Hacker

Time to Extend Your Brand to Windows 10

Marketers, if you’re looking for fresh, fertile ground to extend your brand into, jump now on Windows 10.

The Windows 10 app store is a clear path to:

  • Bump up your online store shopper counts
  • Extend ever-available services directly to your Windows customers (which is about 90% of them)
  • Connect with your brand’s demographic in a way that helps you better understand their needs
  • Build brand value by connecting with partners
  • Build brand value by connecting with social media
  • Escape web browser inconsistency that threatens to pull brand value down
  • Escape security/stability issues in popular platforms (e.g. Android) that threatens brand value.
  • Reach more device form factors with a single, less specialized (less expensive) codebase (desktop, tablet, phone, even game consoles and devices)

AND…

Windows 10 is attracting Microsoft’s (and, by extension, arguably) consumer tech’s most valuable territory,

To wrap one’s head around this, it helps to understand recent history a bit. 

Being a “convicted monopoly” put a lot of costly restrictions on Microsoft, and especially Windows, making every OS release from XP to Vista to Windows 7 less than it could have been.  Despite the fact that Windows is still king in the desktop arena by far, Microsoft has done a great job of digging out from under the perception that it has a monopoly in that space.  It dug itself out by connecting Windows to the both to the cloud and to the broader computing device market, including tablets, smartphones, consoles and devices.

Being out from under those restrictions has enabled Microsoft to really make Windows 10 come together in ways that even the incumbent Windows 7 couldn’t.   All indications are that Windows 10 is a hit and will de-throne Windows 7 as the de-facto desktop OS within a couple years. Between re-claimed freedom to innovate, lessons learned, and other market conditions, it’s a no-brainer that Windows 10 has legs.

[Here’s a number to associate with Windows 10:  1 Billion UPGRADES.  (not counting the number of devices that will be sold with Windows 10 on them.)]

What about Social Media?  According to folks like @fondalo:

With nearly 62% of consumers stating that social media has “no influence at all” on their purchasing decisions (Gallup), marketers are faced with substantial hurdles in an ever-increasingly noisy digital landscape. This challenge is further amplified by a CMO Council study showing that only 5 percent of brands feel they are extremely effective at creating experiences that resonate with target audiences.

In fact, most marketers are currently forced to put more resources toward their digital and social efforts, just to maintain their current returns. I believe this gap will continue to widen for larger brands, but smaller more nimble retailers that get creative and deploy proper resources could end up being the big winner.

Finally, it goes without saying that it no longer matters that you’ve extended your brand to iOS (iPhone/iPad) and/or Android.  The app marketplace for those devices, in your space, is saturated… even super-saturated.  You’ve extended your brand to those app stores, and so has every other brand in the world, including all your competitors.   Of course, saturation will occur in the Windows 10 app marketplace, but getting in ahead of the crowd has its advantages.

Never mind the upside potential on phones and tablets (which remains huge, and far more addressable from Windows 10).  The pendulum is swinging back to the desktop/laptop again (for now).

Being a Microsoft appointed Technical Solutions Professional, I can help.  Let me know how I can bring my (and my team, BlueMetal‘s) expertise to bear for you in your goal to make the jump.
In any case, talk to me.  If you’re a marketing technology manager, what do you see as the pros and cons of jumping into the Windows app pool?  
Tech in the 603, The Granite State Hacker

KB3035583 – Where is the Windows 10 Invitation to Upgrade?

I’ve had a lot of folks express confusion over Windows 10…  It is FREE for the vast majority of existing Windows users. (Only some corporate PCs may run into a cash register.)  It’s also very easy to install for the vast majority of users.  I’m so confident with the upgrade process that I’ve handed off one of the URLs below to my folks, and told them to call me if they have a problem… 

The invitation to reserve Windows 10 is triggered from an update that rolls out over WSUS, described by Knowledge Base article KB3035583.  The reservation is essentially passed since the software is officially released, but here’s some detail on it if you’re curious…

The following URL is the KB article, which describes update that triggers the invitation to reserve Windows 10, mentioning that Enterprise machines do not apply:
https://support.microsoft.com/en-us/kb/3035583


The following article indicates that once installed, the KB3035583 update will also exclude itself from being applied Domain Joined machines:
http://rainesy.com/what-is-the-update-kb3035583-you-might-ask/


But the most important question to answer at this point… 
HOW TO UPGRADE TO WINDOWS 10 NOW:

I’ve had a couple links at the ready since I’ve been answering questions like this a lot lately across both business and personal connections…  here’s a post on how to download & install Windows 10 immediately for an individual system: 
www.microsoft.com/en-us/software-download/windows10

If you’re looking for more information on how to roll Windows 10 out across a company infrastructure, there’s a high level set of options, outlined in the following post:
https://technet.microsoft.com/en-us/library/mt158221%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396

There’s a ton of great reasons for a company to deploy Windows 10, including

  • Universal Apps that enable you to extend your code base and/or future code effort across the entire Windows spectrum
  • A host of attractive, industrial-strength BYOD options for more than just tablets and smartphones
  • The most efficient and consistent use of latest generation hardware including touchscreen and security measures

Microsoft is preparing to *upgrade* over a billion Windows devices to Windows 10.   We’re proud to be a part of that, and very happy to help in any capacity we can getting the bits pushed out to all your machines. 


As a developer, I’m very happy to promote the platform I most want to work on… I really feel that Windows 10’s success is the foundation of a lot of others’ success, including my own.

Tech in the 603, The Granite State Hacker

Visual Studio 2015: An Insider’s Review

I apologize I’ve been pretty wrapped up in a little bit of everything, but I wanted to share a piece my colleague, Dave Davis, Architect at BlueMetal Architects wrote for SD Times:

https://www.bluemetal.com/News/Dave-Davis-Published-in-SDTimes

Well worth the read.

Tech in the 603, The Granite State Hacker

The Edge Browser in Windows 10

Today, I was mildly (but pleasantly) surprised when I logged into my laptop and discovered it had updated itself over night to the latest build of the Windows 10 Insider Preview (10158).  I shouldn’t have been surprised, in retrospect… I knew a build was coming, and I left my laptop on overnight…

The first thing I did was run smack into the Edge browser, which is far more polished in this build.  More importantly, this new browser has many features built in… especially Web Notes. 

Web Notes is a feature which, with a touch (or click if you don’t have touch) you can graphically deface (ok, “annotate” or “mark up”) web content.  Even more fun, you can  touch again, and post it to your favorite social media site or even to OneNote.

This one feature really differentiates the browser, in my mind, from just about anything else out there, and makes it much more clear why a replacement for IE is justified.   I’d heard about the feature, but the experience is far cooler than just seeing it. 

Frankly, in the past, I’ve panned Spartan/Edge as nothing more than browser platform fragmentation… a new wedge in the browser market designed to make the browser a harder platform to build viable apps for. After experiencing the WebNotes feature, I find myself wondering if it won’t a)  end Internet Explorer, and b) make the web cool again.

Given the way the Edge browser integrates with OneNote, I also find myself wondering if Edge shouldn’t be considered a part of the Office suite rather than a part of Windows.  That said, I’m aware of the fact that Microsoft has no plans to bring Edge to IOS or Android.

Aside from the myriad of practical content research and sharing applications, I can easily imagine Edge Web Notes being a social media hit, especially.  Who wouldn’t love to draw moustaches on all their friends & family’s profile pictures?

I have not heard if Edge on Windows 10 Mobile will have Web Notes, but I will be fully disappointed if it doesn’t.  It’d definitely make the web more versatile in a mobile form factor.  My Lumia 1520 with build 10149 has Edge on it, but no Web Notes…  yet.  As a colleague of mine points out, Edge is a Universal Platform app, meaning the code should be baked in, even if it’s not exposed in the UI.  I’ll keep ya posted.

Wouldn’t it be cool, also, if MS updated the Apache Cordova platform to incorporate Edge as the web view, thereby enabling annotations in apps that use it?

For what it’s worth, I used Edge to compose & edit this post.  Blogger is definitely much happier with Edge than with IE 11.

Tech in the 603, The Granite State Hacker

Intro to Windows 10 Universal Devices and Raspberry Pi

I really enjoyed presenting “Intro to Windows 10 Universal with Raspberry Pi” to the Granite State Windows Platform App Devs (#WPDevNH) this past week. 

Here’s the slides which have a few decent links in them to get you started.

[office src=”https://onedrive.live.com/embed?cid=90A564D76FC99F8F&resid=90A564D76FC99F8F%21470743&authkey=AFGBvV7-jEFyGVA&em=2″ width=”402″ height=”327″]

I will try to get a presentation on the next part of this sometime over the next couple months, with a dive in on the GPIO libraries.

Check out the group’s Meetup site for stuff going on going forward.

http://www.meetup.com/Granite-State-NH-WPDev/

Tech in the 603, The Granite State Hacker

Apache Cordova and SharePoint Online / Office 365

The concept came from a good place, but at this point, the story is best described as “science experiment”, as I mentioned at SharePoint Saturday Boston 2015.  I was working on a cross-platform Apache Cordova project for Windows, Windows Phone and Android when the call for speakers hit.  I said “why not?” and I signed myself up to present it…

The good news is that the story’s not without some worth to someone exploring the idea of hooking into SharePoint from an Apache Cordova-based app. Tools that exist today at least assist in the process.

[office src=”https://onedrive.live.com/embed?cid=90A564D76FC99F8F&resid=90A564D76FC99F8F%21470742&authkey=AF2UYViSqPU21mw&em=2″ width=”402″ height=”327″]

The demo code is mostly about accessing files from your personal SharePoint profile document library (A.K.A. OneDrive for business) and indeed, the code is using file access code in addition to SharePoint connection.  The hardest work in a browser based app is to authenticate with Office 365, and this code does that, and then opens up to the rest of SharePoint…

[office src=”https://onedrive.live.com/embed?cid=90A564D76FC99F8F&resid=90A564D76FC99F8F%21470744&authkey=ABWELP8Z5xOqUSY” width=”98″ height=”120″]