Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Conversion from C# to VB.NET
Message
From
18/04/2013 04:01:45
 
 
To
18/04/2013 02:45:57
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:
01571299
Views:
38
>>After more thinking about this, I think it is normal we are not allowed to assigned a NameObjectCollectionBase object to another one as its main root would differ at first making sense for the error message I am getting at the designer level. It might work for a dictionary but not for a NameObjectCollectionBase object.
>>
>>I will have to try with the locking mechanism instead.
>>
>>In the meantime, if you see a workaround with the 2nd approach or if you would know why I am getting this, feel free to let me know.
>
>NameObjectCollectionBase or dictionary - the class is does not matter
>
>
>I've used the volatile keyword http://msdn.microsoft.com/en-us/library/x13ttww7.aspx
>See also here http://www.yoda.arachsys.com/csharp/threads/volatility.shtml
>
>
>
>	public class AClass
>	{
>		private volatile Dictionary<string, string> Tables_;
>	
>		public Dictionary<string, string> Tables
>		{
>			get; private set; 
>
>		}
>
>		public AClass()
>		{
>			// Initialize Tables
>			Tables_ = new Dictionary<string, string>();
>			Tables_.Add("1", "one");
>			Tables_.Add("2", "two");
>		}
>		public void ReInitializeTables()
>		{
>			// do not set to null
>
>			Dictionary<string, string> tmp = new Dictionary<string, string>();
>			tmp.Add("3", "three");
>			tmp.Add("4", "four");
>
>			Tables_ = tmp;  // assign new initialized object
>
>		}
>	}
IIRC, VB doesn't have 'volatile' - maybe Monitor class ?

But, still not understanding enough about Michel's system, I'm not sure locking at this level will resolve the issue. True - it will guarantee that the hit does not receive an inconsistent or out of date version of the data on entry. But it does not prevent the reverse - data being changed on another thread before the hit exits. The only way to do that would be to hold a lock on the 'hit' thread until it completed - obviously not practical for a IIS site ?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform