Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Conversion from C# to VB.NET
Message
De
17/04/2013 17:57:53
 
 
À
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:
01571276
Vues:
47
>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");
>			}
>		}
>	}
>
>
I do not think this is possible either. Your example is using a dictionary list. I am using a NameObjectCollectionBase. And, the item I need to lock is at level 2 at the NameObjectCollectionBase object. So, oApp.Tables is where the lock should occur. I really do not know how we can apply a lock at the second level and also with a Get/Set property approach.

So, both suggestions you sent are great but they just do not apply to the current infrastructure I have. It sounded interesting at first, especially the second one. But, while having tried to make the second one work, I realized it might make sense that it just cannot work. Unless I am missing something...
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