Lloyd Dupont
10/18/2003 11:52:00 PM
mmhh.. better follow your belief, I believe.... ;-)
"Michael Giagnocavo [MVP]" <mggUNSPAM@Atrevido.net> a écrit dans le message
de news:uvlMmPclDHA.2080@TK2MSFTNGP10.phx.gbl...
> I believe that only 32-bit operations are atomic (writing a long is not).
> Thus, if assigning by value a longer struct could get corrupted. This
won't
> happen with reference types (since only the 32bit reference is copied).
>
> -mike
> MVP
>
> "Lloyd Dupont" <net.galador@ld> wrote in message
> news:%23oji7lZlDHA.744@tk2msftngp13.phx.gbl...
> > I have multiple thread which do some operation in a class and I have a
> > DateTime LastOperation;
> > value which is write without lock like:
> > void DoSomething()
> > {
> > // something
> > LastOperation = DateTime.Now;
> > }
> >
> > I avoid lock, because the value is not critical at all and could be
false
> I
> > don't care. However I don't want it to be corrupted !
> >
> > So I wonder if mulitple thread at a time call something like
> > myStructField = aStructValue;
> >
> > is it an affectation (which is thread safe) or a copy (which is thread
> > unsafe) ?
> > and in the particular case of DateTime which just a long internally (I
> > suppose) is it safe anyway ?
> >
> >
>
>