I was the one that advised that this might not be the correct list to post to. I am relatively new to the list and although I am not exactly sure of the scope of this list, though the e-mails I have seen so far have been much more advanced in subject matter than what further discussion off-list uncovered this thread to regard. So my perception could be incorrect, which is why I qualified my suggestion when I made it, perhaps too weakly. Probably I should just lurk for a while longer to get a good feel for the list's content.
What I found to be the question was: "Do distinct instances of a class hold references to the same member variable data?" In code: public class Foo { public string Bar = "unchanged"; } public void Main() { Foo foo1 = new Foo(); Foo foo2 = new Foo(); foo1.Bar = "new value"; if( foo1.Bar == foo2.Bar ) { //Answer is Yes } else { //Answer is No } } The full conversation follows (ordered by time): > I usually define something like (C#): > > private object _lock = new object(); > > then, in the areas where concurrent access could be problematic: > > lock( _lock ) { > //Do things that need to be protected from multi-threaded issues. > } > > There are good resources on this subject on the web. What I have > written is the simplest approach, there are many others that are > often better depending on the situation. You should evaluate them > in regards to your own. > > Erik NEXT MESSAGE: > Hi. Thanks for the reply. I'm not sure if it applies in my situation; > here's an example: > > ----- 8< ----- > Dim MessageMI1 As New CommMessageMI1 > MessageMI1.Model = Me.hidModel.Value.ToString MessageMI1.Chassis = > Me.hidChassis.Value.ToString > ----- >8 ----- > > CommMessageMI1 is derived from another class CommMessage > ----- 8< ----- > Public Class CommMessage > Public intUserID As Integer > Public strModel As String > Public strChassis As String > > Public Property Model() As String > Get > Return strModel > End Get > Set(ByVal value As String) > strModel = value > End Set > End Property > Public Property Chassis() As String > Get > Return strChassis > End Get > Set(ByVal value As String) > strChassis = value > End Set > End Property > End Class > ----- >8 ----- > > What I am worried about is if I set the Model and Chassis propreties > of my instance 'MessageMI1', and another user creates an instance in > another session, will the Model and Chassis properties be changed in > all other instances? > > I hope that makes sense - bit new to OOP here. > Ben NEXT MESSAGE: > I'm not hugely familiar with ASP, but here's what I think: > > If the second user is actually creating a new instance (and thus > you really have distinct instances), then the values inside of > them should be references to different locations in memory. > Encapsulation should enforce this. > > The question I have is why you haven't just written up a test to > find out? How could you test your understanding and discern which > is the case (that both change or that they are separate)? It would > take less time generally to test than try and get an answer from > someone else and you'll end up learning about the technology in > the process. > > As a meta-note. I am new to this list, but I don't believe that > these sorts of basic questions are appropriate here. Instead, most > of the posts I've seen are discussions of fundamental choices about > the language and conceptual understanding of the same. > > Erik (I was thinking, for example of the recent why isn't virtual a part of the default method signature in DotNet) Incidentally, the following e-mail uncovered a more basic and wide ranging discussion point that could be of much more interest (load issues), but ought to be (IMO) further drilled into for the purpose of forming a question (though I hadn't said so yet). The relevant excerpt: > I have written and tested this but have not managed to re-create > the situation I experienced (heavy load) that drew my attention to > the problem. This subject may be of value here and I did in no way intend to discourage Ben in finding an answer, but I was unaware of the wider issue (or any related details) at the time I made my suggestion. Quite possibly I could use some education regarding list content. Sorry for any offense, Erik -----Original Message----- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Stoyan Damov Sent: Tuesday, February 27, 2007 12:49 PM To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: Re: Creating thread-safe classes to use in an ASP.NET app On 2/27/07, Ben Joyce <[EMAIL PROTECTED]> wrote: > I've been advised off-list that this is not the place to ask this sort > of questions, my apologies. > > Ben Does this mean that: a) multithreading is NOT an advanced topic or b) mentioning ASP.NET along with multithreading makes your post off-topic? This is silly. Cheers, Stoyan =================================== This list is hosted by DevelopMentor(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentor® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com