Class MainLoop
Simple main loop implementation that can be used to monitor
file descriptor, run timers and idle handlers.
Inheritance
System.Object
MainLoop
Remarks
Monitoring of file descriptors is only available on Unix, there
does not seem to be a way of supporting this on Windows.
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
Constructors
| Improve this Doc View SourceMainLoop(IMainLoopDriver)
Creates a new Mainloop.
Declaration
public MainLoop(IMainLoopDriver driver)
Parameters
Type | Name | Description |
---|---|---|
IMainLoopDriver | driver | Should match the ConsoleDriver (one of the implementations UnixMainLoop, NetMainLoop or WindowsMainLoop). |
Properties
| Improve this Doc View SourceDriver
The current IMainLoopDriver in use.
Declaration
public IMainLoopDriver Driver { get; }
Property Value
Type | Description |
---|---|
IMainLoopDriver | The driver. |
IdleHandlers
Gets a copy of the list of all idle handlers.
Declaration
public ReadOnlyCollection<Func<bool>> IdleHandlers { get; }
Property Value
Type | Description |
---|---|
System.Collections.ObjectModel.ReadOnlyCollection<System.Func<System.Boolean>> |
Timeouts
Gets the list of all timeouts sorted by the System.TimeSpan time ticks./>.
A shorter limit time can be added at the end, but it will be called before an
earlier addition that has a longer limit time.
Declaration
public SortedList<long, MainLoop.Timeout> Timeouts { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.SortedList<System.Int64, MainLoop.Timeout> |
Methods
| Improve this Doc View SourceAddIdle(Func<Boolean>)
Adds specified idle handler function to mainloop processing. The handler function will be called once per iteration of the main loop after other events have been handled.
Declaration
public Func<bool> AddIdle(Func<bool> idleHandler)
Parameters
Type | Name | Description |
---|---|---|
System.Func<System.Boolean> | idleHandler | Token that can be used to remove the idle handler with RemoveIdle(Func<Boolean>) . |
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 |
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 |
Invoke(Action)
Runs
action
on the thread that is processing events
Declaration
public void Invoke(Action action)
Parameters
Type | Name | Description |
---|---|---|
System.Action | action | the action to be invoked on the main processing thread. |
MainIteration()
Runs one iteration of timers and file watches
Declaration
public void MainIteration()
RemoveIdle(Func<Boolean>)
Removes an idle handler added with AddIdle(Func<Boolean>) from processing.
Declaration
public bool RemoveIdle(Func<bool> token)
Parameters
Type | Name | Description |
---|---|---|
System.Func<System.Boolean> | token | A token returned by AddIdle(Func<Boolean>) |
Returns
Type | Description |
---|---|
System.Boolean |
RemoveTimeout(Object)
Removes a previously scheduled timeout
Declaration
public bool RemoveTimeout(object token)
Parameters
Type | Name | Description |
---|---|---|
System.Object | token |
Returns
Type | Description |
---|---|
System.Boolean |
Run()
Runs the mainloop.
Declaration
public void Run()
Stop()
Stops the mainloop.
Declaration
public void Stop()
Events
| Improve this Doc View SourceTimeoutAdded
Invoked when a new timeout is added to be used on the case
if ExitRunLoopAfterFirstIteration is true,
Declaration
public event Action<long> TimeoutAdded
Event Type
Type | Description |
---|---|
System.Action<System.Int64> |