Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using SyncLock
Message
From
24/01/2011 14:05:51
 
 
To
24/01/2011 13:26:00
General information
Forum:
ASP.NET
Category:
Other
Title:
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01496120
Message ID:
01497248
Views:
52
>>>Let's ask Viv/Bonnie
>>>
>>>I think if you add an initializer to the dictionary of Framework.App, or add code to initialize the dictionary in the Framework.App constructor, you do not need a lock
>>>
>>>Viv, Bonnie - anyone ?
>>
>>Based on what I read in the last few messages, it does seem that we need it, which is what I discovered a few weeks ago which led to this architecture.
>
>
>John Skeet shows an implementation (C#) here w/o explicit locking.
>
>http://csharpindepth.com/Articles/General/Singleton.aspx

And http://csharpindepth.com/Articles/General/BeforeFieldInit.aspx leads to this:
class Test
{
    public static string x = EchoAndReturn ("In type initializer");

    public static string EchoAndReturn (string s)
    {
        Console.WriteLine (s);
        return s;
    }
}

class Driver
{
    public static void Main()
    {
        Console.WriteLine("Starting Main");
        // Invoke a static method on Test
        Test.EchoAndReturn("Echo!");
        Console.WriteLine("After echo");
        // Reference a static field in Test
        string y = Test.x;
        // Use the value just to avoid compiler cleverness
        if (y != null)
        {
            Console.WriteLine("After field access");
        }
    }
}
I don't think this guy should be allowed out :-}
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform