April 15th, 2016

What happens if I call EnumPropsEx while another thread is mutating the properties?

Following up on the question Are SetProp and RemoveProp thread-safe?, you might wonder what happens if you call Enum­Props­Ex while another thread is mutating the properties?

The answer is similar to what you get if you call Find­First­File / Find­Next­File while somebody else is creating or deleting files.

  • If a property is created after the enumeration starts, then it is unspecified whether it will be reported by Enum­Props­Ex.
  • If a property is deleted after the enumeration starts, then it is unspecified whether it will be reported by Enum­Props­Ex. Special exception: The enumeration callback is allowed to remove the property being enumerated.
  • If a property is modified after the enumeration starts, then it is unspecified whether the value reported by Enum­Props­Ex is the old value or the new value.

Hopefully, nobody is playing games with properties that are so crazy that any of these rules will actually come into play, aside from the special exception.

Topics
Code

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.