Swap order of OnError in FileSystemWatcher.ReadDirectoryChangesCallback on Windows (#83121)
If the directory watching encounters a failure error code other than abort, the Windows implementation raises the Error event and sets EnableRaisingEvents to false. However, because it does so in that order, the Error event handler may or may not see the FSW's EnableRaisingEvents as false, based on whether there's a SynchronizingObject that results in the callback being queued. By swapping the order to always disable first, we can ensure consistency regardless of SynchronizingObject, which also means the Error handler can choose based on the error to set EnableRaisingEvents to true again if it desires.
Showing
想要评论请 注册 或 登录