CleanupContext Event

Fires when the application-defined data stored in one or more contexts needs to be cleaned up.

Syntax

public event OnCleanupContextHandler OnCleanupContext;

public delegate void OnCleanupContextHandler(object sender, CbfilterCleanupContextEventArgs e);

public class CbfilterCleanupContextEventArgs : EventArgs {
  public IntPtr FileContext { get; }
  public IntPtr HandleContext { get; }
  public int ResultCode { get; set; }
}
Public Event OnCleanupContext As OnCleanupContextHandler

Public Delegate Sub OnCleanupContextHandler(sender As Object, e As CbfilterCleanupContextEventArgs)

Public Class CbfilterCleanupContextEventArgs Inherits EventArgs
  Public ReadOnly Property FileContext As IntPtr
  Public ReadOnly Property HandleContext As IntPtr
  Public Property ResultCode As Integer
End Class

Remarks

This event fires after a file or directory is closed, just before any contexts related to it are discarded, giving applications a chance to clean up any information stored in them.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

When a handle to some file or directory is closed, this event will fire if the HandleContext associated with that handle is not IntPtr.Zero. When the last handle to the file or directory is closed, this event will fire if the HandleContext associated with that handle and/or the FileContext associated with that file or directory is not IntPtr.Zero. After this event fires, the applicable contexts are set back to IntPtr.Zero automatically.

Applications that need to know the name of the file or directory this event is firing for should store a copy of said name in the context itself during an earlier event.

This event is optional; it will fire regardless of whether any filter rules are present, but only if FileContext, HandleContext, or both, are not already IntPtr.Zero. Applications that clean up their contexts (and set them back to IntPtr.Zero) when a file is being closed, or earlier, do not need to handle this event.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource isn't available, security checks failed, etc.), set it to a non-zero value to report an appropriate error. Please refer to the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

Copyright (c) 2022 Callback Technologies, Inc. - All rights reserved.
CBFS Filter 2020 .NET Edition - Version 20.0 [Build 8317]