Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Conversion from C# to VB.NET
Message
From
18/04/2013 02:30:26
 
 
To
17/04/2013 17:57:53
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01571173
Message ID:
01571296
Views:
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");
>>			}
>>		}
>>	}
>>
>>
>
>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.

(1) Using NameObjectCollectionBase or Dictionary does not matter

(2) A lock on another object ( here TableLocker ) is used to control the access


>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...
Gregory
Previous
Reply
Map
View

Click here to load this message in the networking platform