Terminal.Gui.MainLoop.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  1. <!DOCTYPE html>
  2. <!--[if IE]><![endif]-->
  3. <html>
  4. <head>
  5. <meta charset="utf-8">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  7. <title>Class MainLoop
  8. </title>
  9. <meta name="viewport" content="width=device-width">
  10. <meta name="title" content="Class MainLoop
  11. ">
  12. <meta name="generator" content="docfx 2.54.0.0">
  13. <link rel="shortcut icon" href="../../favicon.ico">
  14. <link rel="stylesheet" href="../../styles/docfx.vendor.css">
  15. <link rel="stylesheet" href="../../styles/docfx.css">
  16. <link rel="stylesheet" href="../../styles/main.css">
  17. <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
  18. <meta property="docfx:navrel" content="../../toc.html">
  19. <meta property="docfx:tocrel" content="toc.html">
  20. <meta property="docfx:rel" content="../../">
  21. </head> <body data-spy="scroll" data-target="#affix" data-offset="120">
  22. <div id="wrapper">
  23. <header>
  24. <nav id="autocollapse" class="navbar navbar-inverse ng-scope" role="navigation">
  25. <div class="container">
  26. <div class="navbar-header">
  27. <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar">
  28. <span class="sr-only">Toggle navigation</span>
  29. <span class="icon-bar"></span>
  30. <span class="icon-bar"></span>
  31. <span class="icon-bar"></span>
  32. </button>
  33. <a class="navbar-brand" href="../../index.html">
  34. <img id="logo" class="svg" src="../../images/logo48.png" alt="">
  35. </a>
  36. </div>
  37. <div class="collapse navbar-collapse" id="navbar">
  38. <form class="navbar-form navbar-right" role="search" id="search">
  39. <div class="form-group">
  40. <input type="text" class="form-control" id="search-query" placeholder="Search" autocomplete="off">
  41. </div>
  42. </form>
  43. </div>
  44. </div>
  45. </nav>
  46. <div class="subnav navbar navbar-default">
  47. <div class="container hide-when-search" id="breadcrumb">
  48. <ul class="breadcrumb">
  49. <li></li>
  50. </ul>
  51. </div>
  52. </div>
  53. </header>
  54. <div class="container body-content">
  55. <div id="search-results">
  56. <div class="search-list"></div>
  57. <div class="sr-items">
  58. <p><i class="glyphicon glyphicon-refresh index-loading"></i></p>
  59. </div>
  60. <ul id="pagination"></ul>
  61. </div>
  62. </div>
  63. <div role="main" class="container body-content hide-when-search">
  64. <div class="sidenav hide-when-search">
  65. <a class="btn toc-toggle collapse" data-toggle="collapse" href="#sidetoggle" aria-expanded="false" aria-controls="sidetoggle">Show / Hide Table of Contents</a>
  66. <div class="sidetoggle collapse" id="sidetoggle">
  67. <div id="sidetoc"></div>
  68. </div>
  69. </div>
  70. <div class="article row grid-right">
  71. <div class="col-md-10">
  72. <article class="content wrap" id="_content" data-uid="Terminal.Gui.MainLoop">
  73. <h1 id="Terminal_Gui_MainLoop" data-uid="Terminal.Gui.MainLoop" class="text-break">Class MainLoop
  74. </h1>
  75. <div class="markdown level0 summary">
  76. Simple main loop implementation that can be used to monitor
  77. file descriptor, run timers and idle handlers.
  78. </div>
  79. <div class="markdown level0 conceptual"></div>
  80. <div class="inheritance">
  81. <h5>Inheritance</h5>
  82. <div class="level0"><span class="xref">System.Object</span></div>
  83. <div class="level1"><span class="xref">MainLoop</span></div>
  84. </div>
  85. <div class="inheritedMembers">
  86. <h5>Inherited Members</h5>
  87. <div>
  88. <span class="xref">System.Object.Equals(System.Object)</span>
  89. </div>
  90. <div>
  91. <span class="xref">System.Object.Equals(System.Object, System.Object)</span>
  92. </div>
  93. <div>
  94. <span class="xref">System.Object.GetHashCode()</span>
  95. </div>
  96. <div>
  97. <span class="xref">System.Object.GetType()</span>
  98. </div>
  99. <div>
  100. <span class="xref">System.Object.MemberwiseClone()</span>
  101. </div>
  102. <div>
  103. <span class="xref">System.Object.ReferenceEquals(System.Object, System.Object)</span>
  104. </div>
  105. <div>
  106. <span class="xref">System.Object.ToString()</span>
  107. </div>
  108. </div>
  109. <h6><strong>Namespace</strong>: <a class="xref" href="Terminal.Gui.html">Terminal.Gui</a></h6>
  110. <h6><strong>Assembly</strong>: Terminal.Gui.dll</h6>
  111. <h5 id="Terminal_Gui_MainLoop_syntax">Syntax</h5>
  112. <div class="codewrapper">
  113. <pre><code class="lang-csharp hljs">public class MainLoop</code></pre>
  114. </div>
  115. <h5 id="Terminal_Gui_MainLoop_remarks"><strong>Remarks</strong></h5>
  116. <div class="markdown level0 remarks">
  117. Monitoring of file descriptors is only available on Unix, there
  118. does not seem to be a way of supporting this on Windows.
  119. </div>
  120. <h3 id="constructors">Constructors
  121. </h3>
  122. <a id="Terminal_Gui_MainLoop__ctor_" data-uid="Terminal.Gui.MainLoop.#ctor*"></a>
  123. <h4 id="Terminal_Gui_MainLoop__ctor_Terminal_Gui_IMainLoopDriver_" data-uid="Terminal.Gui.MainLoop.#ctor(Terminal.Gui.IMainLoopDriver)">MainLoop(IMainLoopDriver)</h4>
  124. <div class="markdown level1 summary">
  125. Creates a new Mainloop, to run it you must provide a driver, and choose
  126. one of the implementations UnixMainLoop, NetMainLoop or WindowsMainLoop.
  127. </div>
  128. <div class="markdown level1 conceptual"></div>
  129. <h5 class="decalaration">Declaration</h5>
  130. <div class="codewrapper">
  131. <pre><code class="lang-csharp hljs">public MainLoop(IMainLoopDriver driver)</code></pre>
  132. </div>
  133. <h5 class="parameters">Parameters</h5>
  134. <table class="table table-bordered table-striped table-condensed">
  135. <thead>
  136. <tr>
  137. <th>Type</th>
  138. <th>Name</th>
  139. <th>Description</th>
  140. </tr>
  141. </thead>
  142. <tbody>
  143. <tr>
  144. <td><a class="xref" href="Terminal.Gui.IMainLoopDriver.html">IMainLoopDriver</a></td>
  145. <td><span class="parametername">driver</span></td>
  146. <td></td>
  147. </tr>
  148. </tbody>
  149. </table>
  150. <h3 id="properties">Properties
  151. </h3>
  152. <a id="Terminal_Gui_MainLoop_Driver_" data-uid="Terminal.Gui.MainLoop.Driver*"></a>
  153. <h4 id="Terminal_Gui_MainLoop_Driver" data-uid="Terminal.Gui.MainLoop.Driver">Driver</h4>
  154. <div class="markdown level1 summary">
  155. The current IMainLoopDriver in use.
  156. </div>
  157. <div class="markdown level1 conceptual"></div>
  158. <h5 class="decalaration">Declaration</h5>
  159. <div class="codewrapper">
  160. <pre><code class="lang-csharp hljs">public IMainLoopDriver Driver { get; }</code></pre>
  161. </div>
  162. <h5 class="propertyValue">Property Value</h5>
  163. <table class="table table-bordered table-striped table-condensed">
  164. <thead>
  165. <tr>
  166. <th>Type</th>
  167. <th>Description</th>
  168. </tr>
  169. </thead>
  170. <tbody>
  171. <tr>
  172. <td><a class="xref" href="Terminal.Gui.IMainLoopDriver.html">IMainLoopDriver</a></td>
  173. <td>The driver.</td>
  174. </tr>
  175. </tbody>
  176. </table>
  177. <h3 id="methods">Methods
  178. </h3>
  179. <a id="Terminal_Gui_MainLoop_AddIdle_" data-uid="Terminal.Gui.MainLoop.AddIdle*"></a>
  180. <h4 id="Terminal_Gui_MainLoop_AddIdle_System_Func_System_Boolean__" data-uid="Terminal.Gui.MainLoop.AddIdle(System.Func{System.Boolean})">AddIdle(Func&lt;Boolean&gt;)</h4>
  181. <div class="markdown level1 summary">
  182. Executes the specified @idleHandler on the idle loop. The return value is a token to remove it.
  183. </div>
  184. <div class="markdown level1 conceptual"></div>
  185. <h5 class="decalaration">Declaration</h5>
  186. <div class="codewrapper">
  187. <pre><code class="lang-csharp hljs">public Func&lt;bool&gt; AddIdle(Func&lt;bool&gt; idleHandler)</code></pre>
  188. </div>
  189. <h5 class="parameters">Parameters</h5>
  190. <table class="table table-bordered table-striped table-condensed">
  191. <thead>
  192. <tr>
  193. <th>Type</th>
  194. <th>Name</th>
  195. <th>Description</th>
  196. </tr>
  197. </thead>
  198. <tbody>
  199. <tr>
  200. <td><span class="xref">System.Func</span>&lt;<span class="xref">System.Boolean</span>&gt;</td>
  201. <td><span class="parametername">idleHandler</span></td>
  202. <td></td>
  203. </tr>
  204. </tbody>
  205. </table>
  206. <h5 class="returns">Returns</h5>
  207. <table class="table table-bordered table-striped table-condensed">
  208. <thead>
  209. <tr>
  210. <th>Type</th>
  211. <th>Description</th>
  212. </tr>
  213. </thead>
  214. <tbody>
  215. <tr>
  216. <td><span class="xref">System.Func</span>&lt;<span class="xref">System.Boolean</span>&gt;</td>
  217. <td></td>
  218. </tr>
  219. </tbody>
  220. </table>
  221. <a id="Terminal_Gui_MainLoop_AddTimeout_" data-uid="Terminal.Gui.MainLoop.AddTimeout*"></a>
  222. <h4 id="Terminal_Gui_MainLoop_AddTimeout_System_TimeSpan_System_Func_Terminal_Gui_MainLoop_System_Boolean__" data-uid="Terminal.Gui.MainLoop.AddTimeout(System.TimeSpan,System.Func{Terminal.Gui.MainLoop,System.Boolean})">AddTimeout(TimeSpan, Func&lt;MainLoop, Boolean&gt;)</h4>
  223. <div class="markdown level1 summary">
  224. Adds a timeout to the mainloop.
  225. </div>
  226. <div class="markdown level1 conceptual"></div>
  227. <h5 class="decalaration">Declaration</h5>
  228. <div class="codewrapper">
  229. <pre><code class="lang-csharp hljs">public object AddTimeout(TimeSpan time, Func&lt;MainLoop, bool&gt; callback)</code></pre>
  230. </div>
  231. <h5 class="parameters">Parameters</h5>
  232. <table class="table table-bordered table-striped table-condensed">
  233. <thead>
  234. <tr>
  235. <th>Type</th>
  236. <th>Name</th>
  237. <th>Description</th>
  238. </tr>
  239. </thead>
  240. <tbody>
  241. <tr>
  242. <td><span class="xref">System.TimeSpan</span></td>
  243. <td><span class="parametername">time</span></td>
  244. <td></td>
  245. </tr>
  246. <tr>
  247. <td><span class="xref">System.Func</span>&lt;<a class="xref" href="Terminal.Gui.MainLoop.html">MainLoop</a>, <span class="xref">System.Boolean</span>&gt;</td>
  248. <td><span class="parametername">callback</span></td>
  249. <td></td>
  250. </tr>
  251. </tbody>
  252. </table>
  253. <h5 class="returns">Returns</h5>
  254. <table class="table table-bordered table-striped table-condensed">
  255. <thead>
  256. <tr>
  257. <th>Type</th>
  258. <th>Description</th>
  259. </tr>
  260. </thead>
  261. <tbody>
  262. <tr>
  263. <td><span class="xref">System.Object</span></td>
  264. <td></td>
  265. </tr>
  266. </tbody>
  267. </table>
  268. <h5 id="Terminal_Gui_MainLoop_AddTimeout_System_TimeSpan_System_Func_Terminal_Gui_MainLoop_System_Boolean___remarks">Remarks</h5>
  269. <div class="markdown level1 remarks">
  270. When time time specified passes, the callback will be invoked.
  271. If the callback returns true, the timeout will be reset, repeating
  272. the invocation. If it returns false, the timeout will stop.
  273. The returned value is a token that can be used to stop the timeout
  274. by calling RemoveTimeout.
  275. </div>
  276. <a id="Terminal_Gui_MainLoop_EventsPending_" data-uid="Terminal.Gui.MainLoop.EventsPending*"></a>
  277. <h4 id="Terminal_Gui_MainLoop_EventsPending_System_Boolean_" data-uid="Terminal.Gui.MainLoop.EventsPending(System.Boolean)">EventsPending(Boolean)</h4>
  278. <div class="markdown level1 summary">
  279. Determines whether there are pending events to be processed.
  280. </div>
  281. <div class="markdown level1 conceptual"></div>
  282. <h5 class="decalaration">Declaration</h5>
  283. <div class="codewrapper">
  284. <pre><code class="lang-csharp hljs">public bool EventsPending(bool wait = false)</code></pre>
  285. </div>
  286. <h5 class="parameters">Parameters</h5>
  287. <table class="table table-bordered table-striped table-condensed">
  288. <thead>
  289. <tr>
  290. <th>Type</th>
  291. <th>Name</th>
  292. <th>Description</th>
  293. </tr>
  294. </thead>
  295. <tbody>
  296. <tr>
  297. <td><span class="xref">System.Boolean</span></td>
  298. <td><span class="parametername">wait</span></td>
  299. <td></td>
  300. </tr>
  301. </tbody>
  302. </table>
  303. <h5 class="returns">Returns</h5>
  304. <table class="table table-bordered table-striped table-condensed">
  305. <thead>
  306. <tr>
  307. <th>Type</th>
  308. <th>Description</th>
  309. </tr>
  310. </thead>
  311. <tbody>
  312. <tr>
  313. <td><span class="xref">System.Boolean</span></td>
  314. <td></td>
  315. </tr>
  316. </tbody>
  317. </table>
  318. <h5 id="Terminal_Gui_MainLoop_EventsPending_System_Boolean__remarks">Remarks</h5>
  319. <div class="markdown level1 remarks">
  320. You can use this method if you want to probe if events are pending.
  321. Typically used if you need to flush the input queue while still
  322. running some of your own code in your main thread.
  323. </div>
  324. <a id="Terminal_Gui_MainLoop_Invoke_" data-uid="Terminal.Gui.MainLoop.Invoke*"></a>
  325. <h4 id="Terminal_Gui_MainLoop_Invoke_System_Action_" data-uid="Terminal.Gui.MainLoop.Invoke(System.Action)">Invoke(Action)</h4>
  326. <div class="markdown level1 summary">
  327. Runs @action on the thread that is processing events
  328. </div>
  329. <div class="markdown level1 conceptual"></div>
  330. <h5 class="decalaration">Declaration</h5>
  331. <div class="codewrapper">
  332. <pre><code class="lang-csharp hljs">public void Invoke(Action action)</code></pre>
  333. </div>
  334. <h5 class="parameters">Parameters</h5>
  335. <table class="table table-bordered table-striped table-condensed">
  336. <thead>
  337. <tr>
  338. <th>Type</th>
  339. <th>Name</th>
  340. <th>Description</th>
  341. </tr>
  342. </thead>
  343. <tbody>
  344. <tr>
  345. <td><span class="xref">System.Action</span></td>
  346. <td><span class="parametername">action</span></td>
  347. <td></td>
  348. </tr>
  349. </tbody>
  350. </table>
  351. <a id="Terminal_Gui_MainLoop_MainIteration_" data-uid="Terminal.Gui.MainLoop.MainIteration*"></a>
  352. <h4 id="Terminal_Gui_MainLoop_MainIteration" data-uid="Terminal.Gui.MainLoop.MainIteration">MainIteration()</h4>
  353. <div class="markdown level1 summary">
  354. Runs one iteration of timers and file watches
  355. </div>
  356. <div class="markdown level1 conceptual"></div>
  357. <h5 class="decalaration">Declaration</h5>
  358. <div class="codewrapper">
  359. <pre><code class="lang-csharp hljs">public void MainIteration()</code></pre>
  360. </div>
  361. <h5 id="Terminal_Gui_MainLoop_MainIteration_remarks">Remarks</h5>
  362. <div class="markdown level1 remarks">
  363. You use this to process all pending events (timers, idle handlers and file watches).
  364. You can use it like this:
  365. while (main.EvensPending ()) MainIteration ();
  366. </div>
  367. <a id="Terminal_Gui_MainLoop_RemoveIdle_" data-uid="Terminal.Gui.MainLoop.RemoveIdle*"></a>
  368. <h4 id="Terminal_Gui_MainLoop_RemoveIdle_System_Func_System_Boolean__" data-uid="Terminal.Gui.MainLoop.RemoveIdle(System.Func{System.Boolean})">RemoveIdle(Func&lt;Boolean&gt;)</h4>
  369. <div class="markdown level1 summary">
  370. Removes the specified idleHandler from processing.
  371. </div>
  372. <div class="markdown level1 conceptual"></div>
  373. <h5 class="decalaration">Declaration</h5>
  374. <div class="codewrapper">
  375. <pre><code class="lang-csharp hljs">public void RemoveIdle(Func&lt;bool&gt; idleHandler)</code></pre>
  376. </div>
  377. <h5 class="parameters">Parameters</h5>
  378. <table class="table table-bordered table-striped table-condensed">
  379. <thead>
  380. <tr>
  381. <th>Type</th>
  382. <th>Name</th>
  383. <th>Description</th>
  384. </tr>
  385. </thead>
  386. <tbody>
  387. <tr>
  388. <td><span class="xref">System.Func</span>&lt;<span class="xref">System.Boolean</span>&gt;</td>
  389. <td><span class="parametername">idleHandler</span></td>
  390. <td></td>
  391. </tr>
  392. </tbody>
  393. </table>
  394. <a id="Terminal_Gui_MainLoop_RemoveTimeout_" data-uid="Terminal.Gui.MainLoop.RemoveTimeout*"></a>
  395. <h4 id="Terminal_Gui_MainLoop_RemoveTimeout_System_Object_" data-uid="Terminal.Gui.MainLoop.RemoveTimeout(System.Object)">RemoveTimeout(Object)</h4>
  396. <div class="markdown level1 summary">
  397. Removes a previously scheduled timeout
  398. </div>
  399. <div class="markdown level1 conceptual"></div>
  400. <h5 class="decalaration">Declaration</h5>
  401. <div class="codewrapper">
  402. <pre><code class="lang-csharp hljs">public void RemoveTimeout(object token)</code></pre>
  403. </div>
  404. <h5 class="parameters">Parameters</h5>
  405. <table class="table table-bordered table-striped table-condensed">
  406. <thead>
  407. <tr>
  408. <th>Type</th>
  409. <th>Name</th>
  410. <th>Description</th>
  411. </tr>
  412. </thead>
  413. <tbody>
  414. <tr>
  415. <td><span class="xref">System.Object</span></td>
  416. <td><span class="parametername">token</span></td>
  417. <td></td>
  418. </tr>
  419. </tbody>
  420. </table>
  421. <h5 id="Terminal_Gui_MainLoop_RemoveTimeout_System_Object__remarks">Remarks</h5>
  422. <div class="markdown level1 remarks">
  423. The token parameter is the value returned by AddTimeout.
  424. </div>
  425. <a id="Terminal_Gui_MainLoop_Run_" data-uid="Terminal.Gui.MainLoop.Run*"></a>
  426. <h4 id="Terminal_Gui_MainLoop_Run" data-uid="Terminal.Gui.MainLoop.Run">Run()</h4>
  427. <div class="markdown level1 summary">
  428. Runs the mainloop.
  429. </div>
  430. <div class="markdown level1 conceptual"></div>
  431. <h5 class="decalaration">Declaration</h5>
  432. <div class="codewrapper">
  433. <pre><code class="lang-csharp hljs">public void Run()</code></pre>
  434. </div>
  435. <a id="Terminal_Gui_MainLoop_Stop_" data-uid="Terminal.Gui.MainLoop.Stop*"></a>
  436. <h4 id="Terminal_Gui_MainLoop_Stop" data-uid="Terminal.Gui.MainLoop.Stop">Stop()</h4>
  437. <div class="markdown level1 summary">
  438. Stops the mainloop.
  439. </div>
  440. <div class="markdown level1 conceptual"></div>
  441. <h5 class="decalaration">Declaration</h5>
  442. <div class="codewrapper">
  443. <pre><code class="lang-csharp hljs">public void Stop()</code></pre>
  444. </div>
  445. </article>
  446. </div>
  447. <div class="hidden-sm col-md-2" role="complementary">
  448. <div class="sideaffix">
  449. <div class="contribution">
  450. <ul class="nav">
  451. </ul>
  452. </div>
  453. <nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix">
  454. <!-- <p><a class="back-to-top" href="#top">Back to top</a><p> -->
  455. </nav>
  456. </div>
  457. </div>
  458. </div>
  459. </div>
  460. <footer>
  461. <div class="grad-bottom"></div>
  462. <div class="footer">
  463. <div class="container">
  464. <span class="pull-right">
  465. <a href="#top">Back to top</a>
  466. </span>
  467. <span>Generated by <strong>DocFX</strong></span>
  468. </div>
  469. </div>
  470. </footer>
  471. </div>
  472. <script type="text/javascript" src="../../styles/docfx.vendor.js"></script>
  473. <script type="text/javascript" src="../../styles/docfx.js"></script>
  474. <script type="text/javascript" src="../../styles/main.js"></script>
  475. </body>
  476. </html>