question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

INotifyWrite is not called when using asynchronous methods

See original GitHub issue

I 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:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
mcavigellicommented, Apr 22, 2021

I think there are two bugs hidden

  1. 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.

  2. 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

0reactions
mcavigellicommented, May 23, 2021

Thank you for your patience. These bugs should be fixed.

I will publish a release next week. Thank you for your report

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I get a warning in Visual Studio when async ...
Go to Text Editor → Basic → Code Style → Naming. Select Manage Specifications and Add New Specification. Select Method, tick all accessibility...
Read more >
Events And Notification - INotifyWrite Interface
Get Before/After Write events with the INotifyWrite interface.
Read more >
FileHelpers v3.1 - Delimited (CSV) or Fixed Data Import ...
NEW: Async Methods returns IDisposable to allow using() statements that autoclose files on ends or exception. NEW: Events for the Async engines.
Read more >
MultiRecordEngine.cs
searchcode is a free source code search engine. Code snippets and open source (free software) repositories are indexed and searchable.
Read more >
FileHelpers.xml
... <example> This example show the basic use of the async methods in the FileHelperAsymcEngine: <code> <textarea name="code" class="c#"> using FileHelpers; ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found