Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Slow performance on culture
Message
De
20/12/2010 04:49:28
 
 
À
19/12/2010 21:46:56
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01493324
Message ID:
01493341
Vues:
58
>This function, if called numerous time during a transaction, will slow down the process:
>
>
>        ' Format a value
>        ' expN1 Value
>        ' expC1 Separator
>        ' expN2 Number of decimals
>        Public Function GetFormatValue(ByVal tnValue As Double, ByVal tcSeparator As String, _
>         ByVal tnDecimal As Integer) As String
>            Dim lcValue As String = ""
>            Dim loCultureInfo As CultureInfo = Nothing
>
>            ' Based on the language
>            Select Case nLanguage
>
>                ' English
>                Case 1
>                    loCultureInfo = New CultureInfo("en-US")
>
>                    ' French
>                Case 2
>                    loCultureInfo = New CultureInfo("fr-CA")
>
>                    ' Spanish
>                Case 3
>                    loCultureInfo = New CultureInfo("en-US")
>
>                    ' Portuguese
>                Case 4
>                    loCultureInfo = New CultureInfo("en-US")
>
>            End Select
>
>            loCultureInfo.NumberFormat.NumberDecimalSeparator = "."
>            loCultureInfo.NumberFormat.NumberGroupSeparator = tcSeparator
>            loCultureInfo.NumberFormat.NumberDecimalDigits = tnDecimal
>
>            lcValue = tnValue.ToString("N", loCultureInfo)
>
>            Return lcValue
>        End Function
>
>
>I didn't pay attention to it until now. So far, it was mostly used on request for a few displays on a form. But, when being called thousands of times during a hit, this has a significant impact. I am moving the creation of the object at the application initialization level to have it executed only once and store loCultureInfo into oApp.oCultureInfo.

Don't think there's a question here :-}
But I seem to recall suggesting this months ago.....
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform