-
-
Notifications
You must be signed in to change notification settings - Fork 339
New locking model for single log file in native applications with managed parts #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
fluffynuts
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks ok to me, tho I'd really prefer string interpolation instead of concatenation - I'll merge in and fix up myself
|
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) |
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?