Generate Name improvment


Your GenerateName function returns a name only if there is a stack overflow exception. You can just check if findname returns a value
    public static string GenerateName(SilverlightControl plugin)
        while (true)
            string name = "_gen_" + (++s_lastGenerated);
            object result = plugin.Content.FindName(name);
            if (result == null)
                return name;


simonferquel wrote Dec 28, 2007 at 1:45 PM

The problem, is that FindName does not return a null value, but throws an exception on failure.
So we use a try / catch block, and return the name in the catch block (which is when the FindName fails).

wrote Feb 2, 2013 at 3:26 AM