Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Handling first hit on a site
Message
De
27/09/2010 15:26:37
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, États-Unis
 
 
À
27/09/2010 15:15:28
Information générale
Forum:
ASP.NET
Catégorie:
Autre
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:
01482922
Vues:
39
>>I'm handling it using this code:
>>
>>
>>public static class Bootstrapper
>>    {
>>        private static readonly object _lock = new object();
>>        private static bool _initialized;
>>
>>        public static void Bootstrap()
>>        {
>>            if (!_initialized)
>>            {
>>                lock (_lock)
>>                {
>>                    if (!_initialized)
>>                    {
>>                        _initialized = true;
>>
>>                        StructureMapConfiguration.Initialize();
>>
>>                        var startupTasks = ObjectFactory.GetAllInstances<IStartupTask>();
>>
>>                        startupTasks.Each(task => task.Execute());
>>                    }
>>                }
>>            }
>>        }
>>    }
>>
>>
>>I call this in my Application_Start event in the global.asax file. Looks like we had the same concern, but I'm handling it a bit differently by checking the _initialized variable before and after the lock.
>
>The reason I do not need to check it at first, before the lock, is because I have lFirstHit. So, basically, we have the same code.
>
>Thanks

FWIW, I've used this same code several times with no issues, so I imagine the logic is sound.
Very fitting: http://xkcd.com/386/
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform