Loading user information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading user information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements


William Stacey staceyw Before C# there was darkness...
  • COM Port being locked up

    I wonder what device the issue is on?  If you app crashes, I suspect the modem never knows it and keeps listening.  The app tries to reconnect to a "connected" port in use on the modem.  Loosing CD I would think reset the modem.  Maybe the manual on the modem would shed light on some CD timeout or some other timeouts.  On the windows side, you should be able to close the comm port in a Catch block on a crash and also possibly send a reset to the modem and restart the app in a top level catch.  If your app just unplugged or losses power, that should be clean on the windows side, because your starting from cold boot.  I suspect it is the modem not resetting and playing with some timeout AT commands may be needed when configuring the modem on start (or firmware settings).  I have similar issues debugging Net MF devices sometimes and VS depending on what state I left the device after detaching the last time. Most of the time resetting the device, allows VS to Deploy right after.  For a production situation, you may need to go as far as a Relay and controlling the modems power from your device.  Another thing you may need some kind of serial port breakout sniffer to shed light on what is going - if you can repro issue this should point to issue directly. I shiver remembering 1200-4800 modems, AT command, serial break outs, etc, in the early days.  Man. I actually did TCP over a 9600 modem on windows 3.x using some Trumpet WinSock IP stack. Ug.

  • Observers leaking down to hardware devices

    Hope this makes Eric smile a little. A question on TinyClr NETMF forum prompted this. The question was related to looking at a Cpu.Pin stream for a certain pattern. Right away I thought of Rx. However a 35K+ port of Rx is overkill. But mixing in some of the ideas, I was able to come up with two (very handy I think) extention methods that get the job done in a composable way.  You subscribe to an event pin with an observer and do what you need.  I thought it was cool.

    public delegate bool PinChange(bool state, DateTime time);
    public delegate bool PinChangeSpan(bool state, long tickSpan);
    public static class Extentions
        /// <summary>
        /// This overload passes tick span between pin changes.
        /// </summary>
        public static void Subscribe(this InterruptPort port, PinChangeSpan predicate)
            if (predicate == null) throw new ArgumentNullException("predicate");
            long lastTick = -1;
            port.Subscribe((bool state, DateTime dt) =>
                    if (lastTick < 0)
                        lastTick = dt.Ticks;
                        // The first "real" pin change has no delta yet.
                        return predicate(state, -1);
                    long delta = dt.Ticks - lastTick;
                    lastTick = dt.Ticks;
                    return predicate(state, delta);
                }, 1); // Always skip first as dirty because no idea when it was set.
        /// <summary>
        /// This overload passes DateTime of current pin state.
        /// </summary>
        /// <param name="predicate">User predicate.</param>
        /// <param name="skipCount">Number of changes to skip.</param>
        public static void Subscribe(this InterruptPort port, PinChange predicate, uint skipCount=0)
            if (predicate == null) throw new ArgumentNullException("predicate");
            NativeEventHandler del = null;
            del = (uint data1, uint data2, DateTime time) =>
                if (skipCount > 0)
                if (del == null)
                    return; // Already unregisted. Not sure why this needed to avoid extra callback. MF Bug?
                bool state = data2 == 0 ? false : true;
                // If user predicate not want more, then unregister.
                if (! predicate(state, time))
                    port.OnInterrupt -= del;
                    del = null;
            // Register observer.
            port.OnInterrupt += del;

    Usage samples:

    InterruptPort inPort = new InterruptPort((Cpu.Pin)FEZ_Pin.Interrupt.Di13, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth);
    int highCount = 0; // local state var.
    inPort.Subscribe((isHigh, dt) =>
        if (isHigh && ++highCount >= 5)
            Debug.Print("Pin high 5 times. Do something.");
            return false; // unsubscribe.
        return true; // keep subscription active.
    // PulseIn sample:
    // Milliseconds span between first low and high.
    inPort.Subscribe((bool isHigh, long ticks) =>
        if (ticks == -1)
            return true; // Skip first, because we have no delta time context yet. 
        if (isHigh)
            Debug.Print("\nDelay between first low and first high: " + ticks / 10000);
            return false; // done.
            return true;

  • Windows Phone 7 Sales Off to a Promising Start, First Step in a New Era of Mobile

    In this economy, the fact they sold any seems like a good sign. The first iphone was shipped before the crash IIRC. Anyway, lets hear from people who own both. What likes/dislikes?

  • My Favorite Things (Box style)

    Back by popular demand. Posted again this year is the best holiday song in the history of the world. Smiley
    (Please sing along)

    If language is VB, me thinks I go doo-doo.
    Loves me some C# with braces and strudel.
    Mem'ry and thread pools all tied up with strings,
    Multi-line lambdas makes four cores just sing.

    When the queues pop,
    and the locks drop,
    when I'm feeling sad.
    I simply remember my favorite things,
    and then I don't feel sooooo bad.

    Merry Christmas to all,
    and to all a good build!

  • NETMF FLL-Like League

    I have been eagerly awaiting production to use the gadgeteer stuff Smiley 

  • NETMF FLL-Like League

    Pic of how crazy it gets.

  • NETMF FLL-Like League

    Our team received a trophy at FLL State comp on Saturday!  I think they finished 14th out of 50 overall and won Core Values part. There was like a thousand people - it was crazy. The experience and popularity of the First Lego Leaugue got me thinking.  The whole time helping the kids work with NXT software, I was thinking how much easier it would be if we could use a NETMF robot and C#. IMO, the VPL gets more in the way then it helps. In some ways, it is a steeper learning curve then code.  Naturally, Legos will not allow that (they want to sell bricks).  Why not start a MS NETMF based robot challenge?  Just start small in a couple states and build it.  I would be willing to help in MI and could also work with Gus over at GHI (also in MI).  I could see it getting at least as popular as FLL after a few years.  With the Gadgeteer stuff coming out, would be at least as plug and play as NXT, but a lot more flexible and capable.  Can also ramp from FLL simple to full blown on same platform so don't run into road blocks. Anyone at MS want to toss around some ideas?


  • Video idea

    Hi Charles.  Colins and Micro Framework have a new thing called Gadgeteer project.

    Kinda a way to make hardware composable and functional.  Being that Eric has passion for factory automation and is functional king, maybe a talk with Colins and Eric would be really neat.  Maybe get Guss from TinyCLR also.  What would it mean for software to have functional hardware? What other ideas could come from thinking down those lines?

    What if I could keep chaining sensors to each other end for end.  What if I could model a Rx pipeline onto that chain and do interesting things.  Could a hardware/software hybrid type of composability be interesting or useful?  What would that look like?

  • What's the dual of the universe?

    If "time is an illusion that has a purpose" like Edgar Casey said, then it would seem we need to figure out what that purpose is by disecting it and playing with it to understand all components of it - which is also why we can't figure it out (yet).  Naturally, it may just be:


    var dual = Observable.Empty<Universe>(); 

  • Apple's definition of Streaming

    CKurt said:
    W3bbo said:

    A Liveblog is not the same as a stream.


    Well it's different because QuickTime does run on windows, but they just choose to block Windows's pc's and only alow Mac OSX Snow Leopard. The only reason I can think of is because they don't want to many people watching it.


    Silverlight runs on Windows, Mac's and Linux (although it's an older version). It's not like microsoft is dilibratly blocking those other viewers/browsers. Apple is...

    "Silverlight runs on Windows, Mac's and Linux (although it's an older version). It's not like microsoft is dilibratly blocking those other viewers/browsers. Apple is..."


    Agree.  A curious thing it is just blain dumb move.  Preaching to the converted is like talking to yourself.  You already have that crowd locked up.  You want others to come to the party to sell more beer.  Is this move some fear of SL?