Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Handling first hit on a site
Message
De
27/09/2010 14:55:02
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Handling first hit on a site
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01482914
Message ID:
01482914
Vues:
107
I have adjusted the code which handles the first hit on a site. I had to make a locking adjustment because one of the process was a group type approach so I had to make sure that only one would go in there. Basically, it goes like this when the application starts for a Web site or when it is being recycled:
            ' If this is the first hit
            If lFirstHit Then

                ' Make sure to lock the thread otherwise, it two simultaneous hits are entering
                ' here, which could be the case when the application starts, you could end up in a real mess
                SyncLock loObjectLock

                    ' If the application initialized has been completed by someone else, then, we can skip that part. The scenario here
                    ' is that the first one who get into there will do the setup. But, we need to avoid the other
                    ' one to setup again.
                    If Not oApp.lInitializeWeb Then

                        ' Do initialization here

                        oApp.lInitializeWeb = True
                    End If

                End SyncLock

            End If
Based on my tests, this seems to have resolved the issue. So, while oApp.IInitializeWeb is not set to True, it might well be possible two users are accessing the Web site at first. So, I have added a property at the application level to tell the hit that the Web initialization has been done. So, the first one gets in and lock the thread. When the thread is unlocked, the next one will go in but will skip it as the oApp.lInitializeWeb property has been set.

lFirstHit controls the first hit on the site. So, lFirstHit turns True once this is done so the logic of a hit will never go in this code for as long as the application runs after.

I would just like to verify if someone could see something wrong in there.
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform