Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using SyncLock
Message
From
23/01/2011 17:49:20
 
 
To
15/01/2011 10:22:01
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:
01497095
Views:
56
>Maybe what you really should be checking is the DataDictionary itself? I typically use code like this (similar to what Viv posted). I've seen it referred to as the "double-check locking pattern":
>
>
>If MyDataDictionary Is Nothing Then
>    SyncLock LockDictionaryObject
>        If MyDataDictionary Is Nothing Then
>            If Not LoadDataDictionary() Then
>                Return False
>            End If
>            ' Do other stuff
>        End If
>    End SyncLock
>End If	
>
The problem with this approach is that this would be ok if I would only have LoadDataDictionary() to be called in the lock. But, after that, I do more process and I need to keep the lock. So, right now I have this:
            If oApp.lFirstHit Then
                oApp.lFirstHit = False

                SyncLock oApp.oObjectLock
                    If Not oApp.lInitialize Then

                        If Not LoadDataDictionary() Then
                            Return False
                        End If
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?
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform