Skip to content

Conversation

@ksa-triovega
Copy link

@ksa-triovega ksa-triovega commented Aug 18, 2025

Hi,

I added function body to your functions:

  • NotifyChange(...)
  • Cancel(...)

Is it okay to use: ThreadPool.QueueUserWorkItem(()=>...) here? Or would you rather have sync call (without extra thread)?

The lines:

private readonly Dictionary<object, bool> _activeNotifies;
private readonly object _lock = new object();

are only to cancel the recursive call.

Now the client can use it like the following code:

object directoryHandle;
FileStatus fileStatus;
NTStatus createStatus = smb2FileStore.CreateFile(
    out directoryHandle,
    out fileStatus,
    "",
    AccessMask.GENERIC_READ,
    SMBLibrary.FileAttributes.Directory,
    ShareAccess.Read | ShareAccess.Write,
    CreateDisposition.FILE_OPEN,
    CreateOptions.FILE_DIRECTORY_FILE,
    null);

NTStatus notifyStatus = smb2FileStore.NotifyChange(
    out m_ioRequest, 
    directoryHandle, 
    NotifyChangeFilter.FileName | NotifyChangeFilter.DirName | NotifyChangeFilter.Size, 
    true, 
    int.Parse(bufferSizeTextBox.Text), 
    OnNotifyChangeCompleted,  // Your callback
    null); // Custom context, here null

PS: I will add unit tests later, if the concept idea is okay.

@ksa-triovega
Copy link
Author

Hey,

I would like to move this forward whenever you get a chance. Let me know if there is anything I can adjust to make the review easier.

@TalAloni
Copy link
Owner

I appreciate you providing this new functionality and contributing this code.
This is an open source project that I maintain on my spare time, in the very limited time I have I focus on fixing bugs and resolving issues around existing functionality.

New functionality has to be vetted extensively to ensure that it's usable by most users and that I can support it,
I want to take a close look at providing ChangeNotify support for the client - and evaluate whether your code is the best code - I have more things I want to do than time to do them - I will try to get to it when time permits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants