Skip to main content
Code Review

Return to Answer

Thread.MemoryBarrier()

What do you expect the call to Thread.MemoryBarrier() will help your code ?

What does Thread.MemoryBarrier do ? It prevents that the compiler and the hardware subtly transform a program’s memory operations.

So basically for your code it ensures that then following instructions will be executed in the order they are written.

var sync = new Control();
sync.Handle.GetHashCode(); // ensure handle is created
_sync = sync; 

Thread safety

To answer "Is this code thread safe ?", you first need to set your definition of thread safety aka what does thread safety means for you. See also what-is-this-thing-you-call-thread-safe what-is-this-thing-you-call-thread-safe

General

Thread.MemoryBarrier()

What do you expect the call to Thread.MemoryBarrier() will help your code ?

What does Thread.MemoryBarrier do ? It prevents that the compiler and the hardware subtly transform a program’s memory operations.

So basically for your code it ensures that then following instructions will be executed in the order they are written.

var sync = new Control();
sync.Handle.GetHashCode(); // ensure handle is created
_sync = sync; 

Thread safety

To answer "Is this code thread safe ?", you first need to set your definition of thread safety aka what does thread safety means for you. See also what-is-this-thing-you-call-thread-safe

General

Thread.MemoryBarrier()

What do you expect the call to Thread.MemoryBarrier() will help your code ?

What does Thread.MemoryBarrier do ? It prevents that the compiler and the hardware subtly transform a program’s memory operations.

So basically for your code it ensures that then following instructions will be executed in the order they are written.

var sync = new Control();
sync.Handle.GetHashCode(); // ensure handle is created
_sync = sync; 

Thread safety

To answer "Is this code thread safe ?", you first need to set your definition of thread safety aka what does thread safety means for you. See also what-is-this-thing-you-call-thread-safe

General

Commonmark migration
Source Link

Thread.MemoryBarrier()

What do you expect the call to Thread.MemoryBarrier() will help your code ?

What does Thread.MemoryBarrier do ? It prevents that the compiler and the hardware subtly transform a program’s memory operations.

So basically for your code it ensures that then following instructions will be executed in the order they are written.

var sync = new Control();
sync.Handle.GetHashCode(); // ensure handle is created
_sync = sync; 

Thread safety

To answer "Is this code thread safe ?", you first need to set your definition of thread safety aka what does thread safety means for you. See also what-is-this-thing-you-call-thread-safe

General

  • the code is lacking a EndInvoke() which should be integrated.

    the code is lacking a EndInvoke() which should be integrated.

  • you are misusing a Control to access the main (ui) thread of an application.

    you are misusing a Control to access the main (ui) thread of an application.

  • wouldn't a SynchronizationContext be a better fit here ?

    wouldn't a SynchronizationContext be a better fit here ?

    See also: https://stackoverflow.com/a/20300351/2655508

See also: https://stackoverflow.com/a/20300351/2655508

Thread.MemoryBarrier()

What do you expect the call to Thread.MemoryBarrier() will help your code ?

What does Thread.MemoryBarrier do ? It prevents that the compiler and the hardware subtly transform a program’s memory operations.

So basically for your code it ensures that then following instructions will be executed in the order they are written.

var sync = new Control();
sync.Handle.GetHashCode(); // ensure handle is created
_sync = sync; 

Thread safety

To answer "Is this code thread safe ?", you first need to set your definition of thread safety aka what does thread safety means for you. See also what-is-this-thing-you-call-thread-safe

General

  • the code is lacking a EndInvoke() which should be integrated.
  • you are misusing a Control to access the main (ui) thread of an application.
  • wouldn't a SynchronizationContext be a better fit here ?

See also: https://stackoverflow.com/a/20300351/2655508

Thread.MemoryBarrier()

What do you expect the call to Thread.MemoryBarrier() will help your code ?

What does Thread.MemoryBarrier do ? It prevents that the compiler and the hardware subtly transform a program’s memory operations.

So basically for your code it ensures that then following instructions will be executed in the order they are written.

var sync = new Control();
sync.Handle.GetHashCode(); // ensure handle is created
_sync = sync; 

Thread safety

To answer "Is this code thread safe ?", you first need to set your definition of thread safety aka what does thread safety means for you. See also what-is-this-thing-you-call-thread-safe

General

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

Thread.MemoryBarrier()

What do you expect the call to Thread.MemoryBarrier() will help your code ?

What does Thread.MemoryBarrier do ? It prevents that the compiler and the hardware subtly transform a program’s memory operations.

So basically for your code it ensures that then following instructions will be executed in the order they are written.

var sync = new Control();
sync.Handle.GetHashCode(); // ensure handle is created
_sync = sync; 

Thread safety

To answer "Is this code thread safe ?", you first need to set your definition of thread safety aka what does thread safety means for you. See also what-is-this-thing-you-call-thread-safe

General

  • the code is lacking a EndInvoke() which should be integrated.
  • you are misusing a Control to access the main (ui) thread of an application.
  • wouldn't a SynchronizationContext be a better fit here ?

See also: http://stackoverflow.com/a/20300351/2655508 https://stackoverflow.com/a/20300351/2655508

Thread.MemoryBarrier()

What do you expect the call to Thread.MemoryBarrier() will help your code ?

What does Thread.MemoryBarrier do ? It prevents that the compiler and the hardware subtly transform a program’s memory operations.

So basically for your code it ensures that then following instructions will be executed in the order they are written.

var sync = new Control();
sync.Handle.GetHashCode(); // ensure handle is created
_sync = sync; 

Thread safety

To answer "Is this code thread safe ?", you first need to set your definition of thread safety aka what does thread safety means for you. See also what-is-this-thing-you-call-thread-safe

General

  • the code is lacking a EndInvoke() which should be integrated.
  • you are misusing a Control to access the main (ui) thread of an application.
  • wouldn't a SynchronizationContext be a better fit here ?

See also: http://stackoverflow.com/a/20300351/2655508

Thread.MemoryBarrier()

What do you expect the call to Thread.MemoryBarrier() will help your code ?

What does Thread.MemoryBarrier do ? It prevents that the compiler and the hardware subtly transform a program’s memory operations.

So basically for your code it ensures that then following instructions will be executed in the order they are written.

var sync = new Control();
sync.Handle.GetHashCode(); // ensure handle is created
_sync = sync; 

Thread safety

To answer "Is this code thread safe ?", you first need to set your definition of thread safety aka what does thread safety means for you. See also what-is-this-thing-you-call-thread-safe

General

  • the code is lacking a EndInvoke() which should be integrated.
  • you are misusing a Control to access the main (ui) thread of an application.
  • wouldn't a SynchronizationContext be a better fit here ?

See also: https://stackoverflow.com/a/20300351/2655508

Post Undeleted by Heslacher
added 59 characters in body
Source Link
Heslacher
  • 50.9k
  • 5
  • 83
  • 177
Loading
Post Deleted by Heslacher
Source Link
Heslacher
  • 50.9k
  • 5
  • 83
  • 177
Loading
lang-cs

AltStyle によって変換されたページ (->オリジナル) /