Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Conversion from C# to VB.NET
Message
De
17/04/2013 13:50:02
 
 
À
17/04/2013 13:33:09
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:
01571173
Message ID:
01571249
Vues:
36
>Have you tried using a lock ?
>
>In the code below, anyone accessing Tables will block if Tables is being reinitialized
>
>
>	public class AClass
>	{
>		private Dictionary<string, string> Tables_;
>		private object TableLocker = new Object();
>
>
>		public Dictionary<string, string> Tables
>		{
>			get 
>			{
>				lock (TableLocker)
>				{
>					return Tables_;
>				}
>			}
>			private set
>			{
>					Tables_ = value;
>			}
>		}
>
>		public void ReInitalizeTables()
>		{
>			lock (TableLocker)
>			{
>				Tables_ = new Dictionary<string, string>();
>				Tables_.Add("1", "one");
>				Tables_.Add("2", "two");
>			}
>		}
>	}
>
>
This seems to be fantastic. I never thought about applying a lock at the reset of an object. I will verify this and will let you know. Thanks
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform