Share via


DispatchSource.VnodeMonitor Class

Definition

Sources of this type monitor the virtual filesystem nodes for state changes.

public class DispatchSource.VnodeMonitor : CoreFoundation.DispatchSource
type DispatchSource.VnodeMonitor = class
    inherit DispatchSource
Inheritance

Remarks

var stream = File.Create ("Demo.txt");

// Get the underlying Unix file descriptor
var safeHandle = stream.SafeFileHandle;
IntPtr descriptor = safeHandle.DangerousGetHandle ();
int fileDescriptor = descriptor.ToInt32 ();

var dispatchSource = new DispatchSource.VnodeMonitor (
    fileDescriptor,
    VnodeMonitorKind.Delete | VnodeMonitorKind.Extend | VnodeMonitorKind.Write,
    DispatchQueue.MainQueue
);

dispatchSource.SetRegistrationHandler (() => {
    Console.WriteLine ("Vnode monitor registered");
});

dispatchSource.SetEventHandler (() => {
    var observedEvents = dispatchSource.ObservedEvents;
    Console.WriteLine ("Vnode monitor event for file: {0}", observedEvents);
    dispatchSource.Cancel ();
    stream.Close ();
});

dispatchSource.SetCancelHandler (() => {
    Console.WriteLine (textView, "Vnode monitor cancelled");
});

dispatchSource.Resume ();

Constructors

Name Description
DispatchSource.VnodeMonitor(Int32, VnodeMonitorKind, DispatchQueue)

Creates a VNode monitor for the specified file descriptor to monitor the specified set of events on it.

DispatchSource.VnodeMonitor(IntPtr, Boolean)
DispatchSource.VnodeMonitor(IntPtr)
DispatchSource.VnodeMonitor(String, VnodeMonitorKind, DispatchQueue)

Creates a VNode monitor for the specified file path to monitor the specified set of events on it.

Properties

Name Description
FileDescriptor

File descriptor that is being monitored

Handle (Inherited from DisposableObject)
IsCanceled

Determine whether the specified source has been canceled.

(Inherited from DispatchSource)
ObservedEvents

Events that were observed on the file.

Owns (Inherited from DisposableObject)

Methods

Name Description
Activate() (Inherited from DispatchObject)
Cancel()

Asynchronously cancels the dispatch source.

(Inherited from DispatchSource)
ClearHandle() (Inherited from DisposableObject)
Dispose() (Inherited from DisposableObject)
Dispose(Boolean)
Equals(Object) (Inherited from DisposableObject)
GetCheckedHandle() (Inherited from DisposableObject)
GetHashCode() (Inherited from DisposableObject)
InitializeHandle(NativeHandle) (Inherited from DisposableObject)
Release() (Inherited from DispatchObject)
Resume()

Resumes the dispatch source.

(Inherited from DispatchSource)
Retain() (Inherited from DispatchObject)
SetCancelHandler(Action)

Provides a cancellation handler

(Inherited from DispatchSource)
SetEventHandler(Action)

Specified a handler to execute when events are received on the dispatch source.

(Inherited from DispatchSource)
SetRegistrationHandler(Action)

Provides a registration handler

(Inherited from DispatchSource)
SetTargetQueue(DispatchQueue) (Inherited from DispatchObject)
Suspend()

Suspends the dispatch source.

(Inherited from DispatchSource)

Extension Methods

Name Description
GetHandle(INativeObject)
GetNonNullHandle(INativeObject, String)

Applies to