Dutton's blog

Google Voice!..... Denied!

I was so excited to receive the email inviting me to sign up for Google Voice this afternoon I didn't read any further than the sign up link, but after logging in was presented with this:
Google Voice... DeniedBah! For those who don't know what Google Voice is and can't figure out why I was so excited, check out the full feature list
here; single phone number for your texts, mobile and landline calls, answer and make calls from anywhere, voicemail transcription to your google account to list but a few, so hurry up Google!!!

Site5 Web Hosting

Over the past few days I've been moving my web hosting to site5. Things seem to be going well so far and fingers crossed the Wordpress transfer of this blog has been relatively painless.

C#'s Null-Coalescing (??) Operator

Although I've always been a big fan of the ternary operator, kudos goes to the Refactoriser (you know who you are!) for pointing me in the direction of an even more effective way of obfsuca^H^H^H tidying up my code; the ?? operator.

The null-coalescing operator (to call it by its more catchy name) allows you to provide an alternative value in the event that the reference type object (or nullable value type) you are trying to access evaluates to null. So instead of having to do something like this:

            int? myNullableInt = null;
            int myInt;


      
Making a function call on another thread using the C# Dispatcher class

There may be a situation when you need to execute a function on a different thread, such as ensuring that calls across the interface between a multi-threaded dll and its single-threaded user are made on the same, single thread. To achive this, you can use the target thread's Dispatcher object as follows:

  1. Create a delegate of the function you wish to be able to call:
    public delegate void MyDelegate(int i, string str);
    public class TargetThreadClass 
    { 
        public TargetThreadClass() 
        { 
            MyDelegate del = new MyDelegate(this.FuncToExec); 
        }  
        public void FuncToExec(int i, string str) 
        { 
           // Do something 
       } 
    }
  2. Within the target thread, create an instance of a Dispatcher object and set it to the thread's current dispatcher:
    Dispatcher UserDispatcher = Dispatcher.CurrentDispatcher;

    Then pass this dispatcher, along with the delegate into the source thread.

  3. Then to call FuncToExec on the target thread, use:
    UserDispatcher.Invoke(del, new object[] { 123, "arg string"});

    Where the first parameter of Invoke is the delegate itself and the second an array of the delegate's parameters (if any), in this example the delegate takes an int and a string.

Time Machine Error: "The backup volume is read only" on NAS (DNS-323)

I wrote a while back here about how I'd set up my D-Link DNS-323 NAS to allow Time Machine backups from my two macs. All has been going well up to a few days ago when I was greeted with this dialog on my MacBook after an automated backup attempt:

Time Machine Error

Nothing has changed on my DNS-323 config-wise and my Mac Mini's Time Machine still works fine, using exactly the same network share as my MacBook and the same username and password so I'm more than a little confused by this!

There are literally hundreds of google search results pointing to forum posts discussing this but they all seem to suggest the same thing; after trying the obvious (Use Disk Utility to repair the drive, done... Power off the drive and mac and restart them both, done....) just reformat your drive. I really don't want to do this so I'm going to keep trying. Will report back my findings, but has anyone out there resolved this issue without a reformat?

Maybe this is the reason Apple turned off support for 'unsupported' network volumes afterall? I really hope not.