Düzenle

Aracılığıyla paylaş


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
DispatchSource.VnodeMonitor
Inheritance
DispatchSource.VnodeMonitor

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

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

FileDescriptor

File descriptor that is being monitored

Handle (Inherited from DispatchObject)
IsCanceled

Determine whether the specified source has been canceled.

(Inherited from DispatchSource)
ObservedEvents

Events that were observed on the file.

Methods

Activate() (Inherited from DispatchObject)
Cancel()

Asynchronously cancels the dispatch source.

(Inherited from DispatchSource)
Check()
Obsolete.
(Inherited from DispatchObject)
Dispose() (Inherited from DispatchObject)
Dispose(Boolean)
Equals(Object) (Inherited from DispatchObject)
GetHashCode()

Returns the hashcode for this object

(Inherited from DispatchObject)
InitializeHandle(IntPtr) (Inherited from NativeObject)
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)

Applies to