Show / Hide Table of Contents

    Class MainLoop

    Simple main loop implementation that can be used to monitor file descriptor, run timers and idle handlers.
    Inheritance
    System.Object
    MainLoop
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: Terminal.Gui
    Assembly: Terminal.Gui.dll
    Syntax
    public class MainLoop
    Remarks
    Monitoring of file descriptors is only available on Unix, there does not seem to be a way of supporting this on Windows.

    Constructors

    MainLoop(IMainLoopDriver)

    Creates a new Mainloop, to run it you must provide a driver, and choose one of the implementations UnixMainLoop, NetMainLoop or WindowsMainLoop.
    Declaration
    public MainLoop(IMainLoopDriver driver)
    Parameters
    Type Name Description
    IMainLoopDriver driver

    Properties

    Driver

    The current IMainLoopDriver in use.
    Declaration
    public IMainLoopDriver Driver { get; }
    Property Value
    Type Description
    IMainLoopDriver The driver.

    Methods

    AddIdle(Func<Boolean>)

    Executes the specified @idleHandler on the idle loop. The return value is a token to remove it.
    Declaration
    public Func<bool> AddIdle(Func<bool> idleHandler)
    Parameters
    Type Name Description
    System.Func<System.Boolean> idleHandler
    Returns
    Type Description
    System.Func<System.Boolean>

    AddTimeout(TimeSpan, Func<MainLoop, Boolean>)

    Adds a timeout to the mainloop.
    Declaration
    public object AddTimeout(TimeSpan time, Func<MainLoop, bool> callback)
    Parameters
    Type Name Description
    System.TimeSpan time
    System.Func<MainLoop, System.Boolean> callback
    Returns
    Type Description
    System.Object
    Remarks
    When time time specified passes, the callback will be invoked. If the callback returns true, the timeout will be reset, repeating the invocation. If it returns false, the timeout will stop. The returned value is a token that can be used to stop the timeout by calling RemoveTimeout.

    EventsPending(Boolean)

    Determines whether there are pending events to be processed.
    Declaration
    public bool EventsPending(bool wait = false)
    Parameters
    Type Name Description
    System.Boolean wait
    Returns
    Type Description
    System.Boolean
    Remarks
    You can use this method if you want to probe if events are pending. Typically used if you need to flush the input queue while still running some of your own code in your main thread.

    Invoke(Action)

    Runs @action on the thread that is processing events
    Declaration
    public void Invoke(Action action)
    Parameters
    Type Name Description
    System.Action action

    MainIteration()

    Runs one iteration of timers and file watches
    Declaration
    public void MainIteration()
    Remarks
    You use this to process all pending events (timers, idle handlers and file watches). You can use it like this: while (main.EvensPending ()) MainIteration ();

    RemoveIdle(Func<Boolean>)

    Removes the specified idleHandler from processing.
    Declaration
    public void RemoveIdle(Func<bool> idleHandler)
    Parameters
    Type Name Description
    System.Func<System.Boolean> idleHandler

    RemoveTimeout(Object)

    Removes a previously scheduled timeout
    Declaration
    public void RemoveTimeout(object token)
    Parameters
    Type Name Description
    System.Object token
    Remarks
    The token parameter is the value returned by AddTimeout.

    Run()

    Runs the mainloop.
    Declaration
    public void Run()

    Stop()

    Stops the mainloop.
    Declaration
    public void Stop()
    Back to top Generated by DocFX