Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using SyncLock
Message
From
23/01/2011 20:09:49
 
 
To
23/01/2011 17:49:20
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:
01497101
Views:
62
This message has been marked as a message which has helped to the initial question of the thread.
>The only improvement I could see here would be to add a verification as you mentioned such as this:
>
>
>            If oApp.lFirstHit Then
>                oApp.lFirstHit = False
>
>                If Not oApp.lInitialize Then
>                    SyncLock oApp.oObjectLock
>                        If Not oApp.lInitialize Then
>
>                            If Not LoadDataDictionary() Then
>                                Return False
>                            End If
>
>
>So, basically, it would avoid using SyncLock if the application has been initialized.
>
>Is this more into what you were trying to explain me?


Yes, that *is* what I meant by the double-check locking pattern (by checking first, you only get the lock if you need to) .... however, it seems to me that if you implement this pattern, then there's no reason that you even need to check both oApp.lFirstHit and oApp.lInitialize, is there? I mean, you're initializing only on the FirstHit anyway, so I would think you could simplify this to just the following:
            If Not oApp.lInitialize Then
                SyncLock oApp.oObjectLock
                    If Not oApp.lInitialize Then
                        If Not LoadDataDictionary() Then
                            Return False
                        End If
And then you could totally remove the lFirstHit property from oApp (unless you're using it for something else also).

~~Bonnie
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform