編集

次の方法で共有


DispatchSource.WriteMonitor Class

Definition

Sources of this type monitor file descriptors for available write buffer space.

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

Remarks

Users of this source type are strongly encouraged to perform non-blocking I/O and handle any truncated reads or error conditions that may occur.

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

// The the unix file handle
var safeHandle = stream.SafeFileHandle;
IntPtr descriptor = safeHandle.DangerousGetHandle ();
int fileDescriptor = descriptor.ToInt32 ();

dispatchSource = new DispatchSource.WriteMonitor (fileDescriptor, DispatchQueue.MainQueue);

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

dispatchSource.SetEventHandler (() => {
    Console.WriteLine ("Write monitor: was opened in write mode")
    dispatchSource.Cancel ();
    stream.Close ();
});

dispatchSource.SetCancelHandler (() => {
    Console.WriteLine ("Write monitor cancelled");
});

dispatchSource.Resume ();

Constructors

DispatchSource.WriteMonitor(Int32, DispatchQueue)

Creates a file descriptor monitor that invokes the event handler when writing to the file descriptor wont block.

DispatchSource.WriteMonitor(IntPtr, Boolean)
DispatchSource.WriteMonitor(IntPtr)

Properties

BufferSpaceAvailable

Buffer space available to write on the file descriptor being monitored.

FileDescriptor

The file descriptor being monitored.

Handle (Inherited from DispatchObject)
IsCanceled

Determine whether the specified source has been canceled.

(Inherited from DispatchSource)

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)

Releases the resources used by the DispatchSource object.

(Inherited from DispatchSource)
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