"how is backgroundworker.cancellationpending thread-safe?" Code Answer


it is thread-safe.
the code

  while (!backgroundworker.cancellationpending) 

is reading a property and the compiler knows it can't cache the result.

and since in the normal framework every write is the same as volatilewrite, the cancelasync() method can just set a field.

By Leo Odishvili on July 25 2022

Answers related to “how is backgroundworker.cancellationpending thread-safe?”

Only authorized users can answer the Search term. Please sign in first, or register a free account.