New locking model for single log file in native applications with managed parts#92
Merged
fluffynuts merged 1 commit intoapache:masterfrom Aug 21, 2022
Merged
Conversation
fluffynuts
approved these changes
Aug 21, 2022
Contributor
fluffynuts
left a comment
There was a problem hiding this comment.
looks ok to me, tho I'd really prefer string interpolation instead of concatenation - I'll merge in and fix up myself
Contributor
Author
|
fixes #259 |
|
Just curious how does NoLock work when having two file-handles to the same file ? Forexample:
Will File-Handle-2 not overwrite the contents just written by File-Handle-1 ? With the following code that disables buffering: using var fileStream1 = new FileStream(@"C:\Temp\Hello.txt", FileMode.Append, FileAccess.Write, FileShare.ReadWrite, 1, FileOptions.None);
using var fileStream2 = new FileStream(@"C:\Temp\Hello.txt", FileMode.Append, FileAccess.Write, FileShare.ReadWrite, 1, FileOptions.None);
fileStream1.Write(System.Text.Encoding.UTF8.GetBytes("Hello"));
fileStream2.Write(System.Text.Encoding.UTF8.GetBytes("Goodbye World"));
fileStream1.Write(System.Text.Encoding.UTF8.GetBytes("World"));Then the contents of the output-file becomes this: If enable FileStream with default buffer-size like this: using var fileStream1 = new FileStream(@"C:\Temp\Hello.txt", FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
using var fileStream2 = new FileStream(@"C:\Temp\Hello.txt", FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
fileStream1.Write(System.Text.Encoding.UTF8.GetBytes("Hello"));
fileStream2.Write(System.Text.Encoding.UTF8.GetBytes("Goodbye World"));
fileStream1.Write(System.Text.Encoding.UTF8.GetBytes("World"));Then the contents of the output-file becomes this: How does one ensure that the 2 FileHandles doesn't generate garbled output with NoLock ? (See also #259) |
This was referenced Aug 19, 2025
This was referenced Nov 11, 2025
This was referenced Jan 7, 2026
This was referenced Jan 27, 2026
This was referenced Feb 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We have a native application (Delphi) which loads .net dlls at runtime.
With this adjustment we can (optionally) share the log file between the native and the managed part of the application.
@fluffynuts Could you please review?