Tiene un EventWaitHandle algún MemoryBarrier implícito?

Nuevo en este sitio web, así que avíseme si no estoy publicando de una manera aceptada.

Frecuentemente he codificado algo en la línea de la muestra a continuación (con cosas como Dispose omitidas por claridad). Mi pregunta es, ¿se necesitan los volátiles como se muestra? ¿O el ManualResetEvent.Set tiene una barrera de memoria implícita como he leído Thread.Start? ¿O sería mejor una llamada explícita de MemoryBarrier que los volátiles? ¿O está completamente mal? Además, el hecho de que el "comportamiento implícito de barrera de memoria" en algunas operaciones no esté documentado hasta donde yo he visto es bastante frustrante, ¿hay alguna lista de estas operaciones en alguna parte?

Gracias, Tom

:

class OneUseBackgroundOp
{

   // background args
   private string _x;
   private object _y;
   private long _z;

   // background results
   private volatile DateTime _a
   private volatile double _b;
   private volatile object _c;

   // thread control
   private Thread _task;
   private ManualResetEvent _completedSignal;
   private volatile bool _completed;

   public bool DoSomething(string x, object y, long z, int initialWaitMs)
   {
      bool doneWithinWait;

      _x = x;
      _y = y;
      _z = z;

      _completedSignal = new ManualResetEvent(false);

      _task = new Thread(new ThreadStart(Task));
      _task.IsBackground = true;
      _task.Start()

      doneWithinWait = _completedSignal.WaitOne(initialWaitMs);

      return doneWithinWait;

   }

   public bool Completed
   {
      get
      {
         return _completed;
      }
   }

   /* public getters for the result fields go here, with an exception
      thrown if _completed is not true; */

   private void Task()
   {
      // args x, y, and z are written once, before the Thread.Start
      //    implicit memory barrier so they may be accessed freely.

      // possibly long-running work goes here

      // with the work completed, assign the result fields _a, _b, _c here

      _completed = true;
      _completedSignal.Set();

   }

}

Respuestas a la pregunta(5)

Su respuesta a la pregunta