INotifyWrite is not called when using asynchronous methods
See original GitHub issueI have several record types that I am using with the MultiRecordEngine which implement the INotifyWrite interface. When I write a file using the WriteFile method, the BeforeWrite and AfterWrite methods are called as expected. When I write a file using the BeginWriteFile and WriteNext methods, the before and after hooks are not called at all. Examining the source code shows that the internal property MustNotifyWrite is not checked during the asynchronous WriteRecord method, while it is checked in the synchronous WriteStream method. This is clearly an oversight, as the asynchronous ReadRecord checks the MustNotifyRead property and functions the same as the synchronous ReadStream method. Please fix this so the before/after write hooks are called when using the asynchronous style methods.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6

Top Related StackOverflow Question
I think there are two bugs hidden
It seems that the logic for writing is duplicated: File MultiRecordEngine, line 392 and line 879. The first occurrence publishes the events, the latter not. The bug should be fixed by removing the (incorrect) duplication.
Also to decide if the events should be fired or not does take into account that the recordinfo changes, as @phumphreys stated. One of the pull requests addresses that problem for reading: https://github.com/MarcosMeli/FileHelpers/pull/256/commits/cdfe2e5c666d9131b9f62674bcb3b6047b788fa1 But it does not consider, wether there is an event subscription on BeforeWriteRecord or AfterWriteRecord.
Thank you for your analysis. Unfortunately I cannot fix these bugs in April. Matthias
Thank you for your patience. These bugs should be fixed.
I will publish a release next week. Thank you for your report