You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

336 lines
16 KiB

  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 Coroutines
  8. </title>
  9. <meta name="viewport" content="width=device-width">
  10. <meta name="title" content="Class Coroutines
  11. ">
  12. <meta name="generator" content="docfx 2.59.4.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 rel="stylesheet" href="../styles/fix.css">
  18. <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
  19. <meta property="docfx:navrel" content="../toc.html">
  20. <meta property="docfx:tocrel" content="toc.html">
  21. <meta property="docfx:rel" content="../">
  22. <meta property="docfx:newtab" content="true">
  23. </head> <body data-spy="scroll" data-target="#affix" data-offset="120">
  24. <div id="wrapper">
  25. <header>
  26. <nav id="autocollapse" class="navbar navbar-inverse ng-scope" role="navigation">
  27. <div class="container">
  28. <div class="navbar-header">
  29. <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar">
  30. <span class="sr-only">Toggle navigation</span>
  31. <span class="icon-bar"></span>
  32. <span class="icon-bar"></span>
  33. <span class="icon-bar"></span>
  34. </button>
  35. <a class="navbar-brand" href="../index.html">
  36. <img id="logo" class="svg" src="../logo.svg" alt="">
  37. </a>
  38. </div>
  39. <div class="collapse navbar-collapse" id="navbar">
  40. <form class="navbar-form navbar-right" role="search" id="search">
  41. <div class="form-group">
  42. <input type="text" class="form-control" id="search-query" placeholder="Search" autocomplete="off">
  43. </div>
  44. </form>
  45. </div>
  46. </div>
  47. </nav>
  48. <div class="subnav navbar navbar-default">
  49. <div class="container hide-when-search" id="breadcrumb">
  50. <ul class="breadcrumb">
  51. <li></li>
  52. </ul>
  53. </div>
  54. </div>
  55. </header>
  56. <div class="container body-content">
  57. <div id="search-results">
  58. <div class="search-list">Search Results for <span></span></div>
  59. <div class="sr-items">
  60. <p><i class="glyphicon glyphicon-refresh index-loading"></i></p>
  61. </div>
  62. <ul id="pagination" data-first="First" data-prev="Previous" data-next="Next" data-last="Last"></ul>
  63. </div>
  64. </div>
  65. <div role="main" class="container body-content hide-when-search">
  66. <div class="sidenav hide-when-search">
  67. <a class="btn toc-toggle collapse" data-toggle="collapse" href="#sidetoggle" aria-expanded="false" aria-controls="sidetoggle">Show / Hide Table of Contents</a>
  68. <div class="sidetoggle collapse" id="sidetoggle">
  69. <div id="sidetoc"></div>
  70. </div>
  71. </div>
  72. <div class="article row grid-right">
  73. <div class="col-md-10">
  74. <article class="content wrap" id="_content" data-uid="IPA.Utilities.Async.Coroutines">
  75. <h1 id="IPA_Utilities_Async_Coroutines" data-uid="IPA.Utilities.Async.Coroutines" class="text-break">Class Coroutines
  76. </h1>
  77. <div class="markdown level0 summary"><p>A class providing coroutine helpers.</p>
  78. </div>
  79. <div class="markdown level0 conceptual"></div>
  80. <div class="inheritance">
  81. <h5>Inheritance</h5>
  82. <div class="level0"><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object">Object</a></div>
  83. <div class="level1"><span class="xref">Coroutines</span></div>
  84. </div>
  85. <div class="inheritedMembers">
  86. <h5>Inherited Members</h5>
  87. <div>
  88. <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.tostring#system-object-tostring">Object.ToString()</a>
  89. </div>
  90. <div>
  91. <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)">Object.Equals(Object)</a>
  92. </div>
  93. <div>
  94. <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)">Object.Equals(Object, Object)</a>
  95. </div>
  96. <div>
  97. <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.referenceequals#system-object-referenceequals(system-object-system-object)">Object.ReferenceEquals(Object, Object)</a>
  98. </div>
  99. <div>
  100. <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.gethashcode#system-object-gethashcode">Object.GetHashCode()</a>
  101. </div>
  102. <div>
  103. <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.gettype#system-object-gettype">Object.GetType()</a>
  104. </div>
  105. <div>
  106. <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone#system-object-memberwiseclone">Object.MemberwiseClone()</a>
  107. </div>
  108. </div>
  109. <h6><strong>Namespace</strong>: <a class="xref" href="IPA.Utilities.Async.html">IPA.Utilities.Async</a></h6>
  110. <h6><strong>Assembly</strong>: IPA.Loader.dll</h6>
  111. <h5 id="IPA_Utilities_Async_Coroutines_syntax">Syntax</h5>
  112. <div class="codewrapper">
  113. <pre><code class="lang-csharp hljs">public static class Coroutines</code></pre>
  114. </div>
  115. <h3 id="methods">Methods
  116. </h3>
  117. <span class="small pull-right mobile-hide">
  118. <span class="divider">|</span>
  119. <a href="https://github.com/nike4613/BeatSaber-IPA-Reloaded/new/master/docs/override/new?filename=IPA_Utilities_Async_Coroutines_AsTask_System_Collections_IEnumerator_.md&amp;value=---%0Auid%3A%20IPA.Utilities.Async.Coroutines.AsTask(System.Collections.IEnumerator)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
  120. </span>
  121. <span class="small pull-right mobile-hide">
  122. <a href="https://github.com/nike4613/BeatSaber-IPA-Reloaded/blob/777adc0222baf310f67c08f6bc259d3acb5338fa/IPA.Loader/Utilities/Async/Coroutines.cs/#L54">View Source</a>
  123. </span>
  124. <a id="IPA_Utilities_Async_Coroutines_AsTask_" data-uid="IPA.Utilities.Async.Coroutines.AsTask*"></a>
  125. <h4 id="IPA_Utilities_Async_Coroutines_AsTask_System_Collections_IEnumerator_" data-uid="IPA.Utilities.Async.Coroutines.AsTask(System.Collections.IEnumerator)">AsTask(IEnumerator)</h4>
  126. <div class="markdown level1 summary"><p>Binds a <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.threading.tasks.task">Task</a> to a Unity coroutine, capturing exceptions as well as the coroutine call stack.</p>
  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 static Task AsTask(IEnumerator coroutine)</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="https://learn.microsoft.com/dotnet/api/system.collections.ienumerator">IEnumerator</a></td>
  145. <td><span class="parametername">coroutine</span></td>
  146. <td><p>the coroutine to bind to a task</p>
  147. </td>
  148. </tr>
  149. </tbody>
  150. </table>
  151. <h5 class="returns">Returns</h5>
  152. <table class="table table-bordered table-striped table-condensed">
  153. <thead>
  154. <tr>
  155. <th>Type</th>
  156. <th>Description</th>
  157. </tr>
  158. </thead>
  159. <tbody>
  160. <tr>
  161. <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.threading.tasks.task">Task</a></td>
  162. <td><p>a <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.threading.tasks.task">Task</a> that completes when <code data-dev-comment-type="paramref" class="paramref">coroutine</code> completes, and fails when it throws</p>
  163. </td>
  164. </tr>
  165. </tbody>
  166. </table>
  167. <h5 id="IPA_Utilities_Async_Coroutines_AsTask_System_Collections_IEnumerator__remarks">Remarks</h5>
  168. <div class="markdown level1 remarks"><p>
  169. This may be called off of the Unity main thread. If it is, the coroutine start will be scheduled using the default
  170. <a class="xref" href="IPA.Utilities.Async.UnityMainThreadTaskScheduler.html">UnityMainThreadTaskScheduler</a> and will be run on the main thread as required by Unity.
  171. </p>
  172. <p>
  173. Unity provides a handful of coroutine helpers that are not <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.ienumerable">IEnumerable</a>s. Most of these are not terribly
  174. helpful on their own, however <span class="xref">UnityEngine.WaitForSeconds</span> may be. Instead, prefer to use the typical .NET
  175. <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.threading.tasks.task.wait#system-threading-tasks-task-wait(system-timespan)">Wait(TimeSpan)</a> or similar overloads, or use <span class="xref">UnityEngine.WaitForSecondsRealtime</span>.
  176. </p>
  177. </div>
  178. <span class="small pull-right mobile-hide">
  179. <span class="divider">|</span>
  180. <a href="https://github.com/nike4613/BeatSaber-IPA-Reloaded/new/master/docs/override/new?filename=IPA_Utilities_Async_Coroutines_WaitForTask_System_Threading_Tasks_Task_.md&amp;value=---%0Auid%3A%20IPA.Utilities.Async.Coroutines.WaitForTask(System.Threading.Tasks.Task)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
  181. </span>
  182. <span class="small pull-right mobile-hide">
  183. <a href="https://github.com/nike4613/BeatSaber-IPA-Reloaded/blob/777adc0222baf310f67c08f6bc259d3acb5338fa/IPA.Loader/Utilities/Async/Coroutines.cs/#L21">View Source</a>
  184. </span>
  185. <a id="IPA_Utilities_Async_Coroutines_WaitForTask_" data-uid="IPA.Utilities.Async.Coroutines.WaitForTask*"></a>
  186. <h4 id="IPA_Utilities_Async_Coroutines_WaitForTask_System_Threading_Tasks_Task_" data-uid="IPA.Utilities.Async.Coroutines.WaitForTask(System.Threading.Tasks.Task)">WaitForTask(Task)</h4>
  187. <div class="markdown level1 summary"><p>Stalls the coroutine until <code data-dev-comment-type="paramref" class="paramref">task</code> completes, faults, or is canceled.</p>
  188. </div>
  189. <div class="markdown level1 conceptual"></div>
  190. <h5 class="decalaration">Declaration</h5>
  191. <div class="codewrapper">
  192. <pre><code class="lang-csharp hljs">public static IEnumerator WaitForTask(Task task)</code></pre>
  193. </div>
  194. <h5 class="parameters">Parameters</h5>
  195. <table class="table table-bordered table-striped table-condensed">
  196. <thead>
  197. <tr>
  198. <th>Type</th>
  199. <th>Name</th>
  200. <th>Description</th>
  201. </tr>
  202. </thead>
  203. <tbody>
  204. <tr>
  205. <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.threading.tasks.task">Task</a></td>
  206. <td><span class="parametername">task</span></td>
  207. <td><p>the <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.threading.tasks.task">Task</a> to wait for</p>
  208. </td>
  209. </tr>
  210. </tbody>
  211. </table>
  212. <h5 class="returns">Returns</h5>
  213. <table class="table table-bordered table-striped table-condensed">
  214. <thead>
  215. <tr>
  216. <th>Type</th>
  217. <th>Description</th>
  218. </tr>
  219. </thead>
  220. <tbody>
  221. <tr>
  222. <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.ienumerator">IEnumerator</a></td>
  223. <td><p>a coroutine waiting for the given task</p>
  224. </td>
  225. </tr>
  226. </tbody>
  227. </table>
  228. <span class="small pull-right mobile-hide">
  229. <span class="divider">|</span>
  230. <a href="https://github.com/nike4613/BeatSaber-IPA-Reloaded/new/master/docs/override/new?filename=IPA_Utilities_Async_Coroutines_WaitForTask_System_Threading_Tasks_Task_System_Boolean_.md&amp;value=---%0Auid%3A%20IPA.Utilities.Async.Coroutines.WaitForTask(System.Threading.Tasks.Task%2CSystem.Boolean)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
  231. </span>
  232. <span class="small pull-right mobile-hide">
  233. <a href="https://github.com/nike4613/BeatSaber-IPA-Reloaded/blob/777adc0222baf310f67c08f6bc259d3acb5338fa/IPA.Loader/Utilities/Async/Coroutines.cs/#L30">View Source</a>
  234. </span>
  235. <a id="IPA_Utilities_Async_Coroutines_WaitForTask_" data-uid="IPA.Utilities.Async.Coroutines.WaitForTask*"></a>
  236. <h4 id="IPA_Utilities_Async_Coroutines_WaitForTask_System_Threading_Tasks_Task_System_Boolean_" data-uid="IPA.Utilities.Async.Coroutines.WaitForTask(System.Threading.Tasks.Task,System.Boolean)">WaitForTask(Task, Boolean)</h4>
  237. <div class="markdown level1 summary"><p>Stalls the coroutine until <code data-dev-comment-type="paramref" class="paramref">task</code> completes, faults, or is canceled.</p>
  238. </div>
  239. <div class="markdown level1 conceptual"></div>
  240. <h5 class="decalaration">Declaration</h5>
  241. <div class="codewrapper">
  242. <pre><code class="lang-csharp hljs">public static IEnumerator WaitForTask(Task task, bool throwOnFault = false)</code></pre>
  243. </div>
  244. <h5 class="parameters">Parameters</h5>
  245. <table class="table table-bordered table-striped table-condensed">
  246. <thead>
  247. <tr>
  248. <th>Type</th>
  249. <th>Name</th>
  250. <th>Description</th>
  251. </tr>
  252. </thead>
  253. <tbody>
  254. <tr>
  255. <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.threading.tasks.task">Task</a></td>
  256. <td><span class="parametername">task</span></td>
  257. <td><p>the <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.threading.tasks.task">Task</a> to wait for</p>
  258. </td>
  259. </tr>
  260. <tr>
  261. <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">Boolean</a></td>
  262. <td><span class="parametername">throwOnFault</span></td>
  263. <td><p>whether or not to throw if the task faulted</p>
  264. </td>
  265. </tr>
  266. </tbody>
  267. </table>
  268. <h5 class="returns">Returns</h5>
  269. <table class="table table-bordered table-striped table-condensed">
  270. <thead>
  271. <tr>
  272. <th>Type</th>
  273. <th>Description</th>
  274. </tr>
  275. </thead>
  276. <tbody>
  277. <tr>
  278. <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.ienumerator">IEnumerator</a></td>
  279. <td><p>a coroutine waiting for the given task</p>
  280. </td>
  281. </tr>
  282. </tbody>
  283. </table>
  284. </article>
  285. </div>
  286. <div class="hidden-sm col-md-2" role="complementary">
  287. <div class="sideaffix">
  288. <div class="contribution">
  289. <ul class="nav">
  290. <li>
  291. <a href="https://github.com/nike4613/BeatSaber-IPA-Reloaded/new/master/docs/override/new?filename=IPA_Utilities_Async_Coroutines.md&amp;value=---%0Auid%3A%20IPA.Utilities.Async.Coroutines%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A" class="contribution-link">Improve this Doc</a>
  292. </li>
  293. <li>
  294. <a href="https://github.com/nike4613/BeatSaber-IPA-Reloaded/blob/777adc0222baf310f67c08f6bc259d3acb5338fa/IPA.Loader/Utilities/Async/Coroutines.cs/#L14" class="contribution-link">View Source</a>
  295. </li>
  296. </ul>
  297. </div>
  298. <nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix">
  299. <h5>In This Article</h5>
  300. <div></div>
  301. </nav>
  302. </div>
  303. </div>
  304. </div>
  305. </div>
  306. <footer>
  307. <div class="grad-bottom"></div>
  308. <div class="footer">
  309. <div class="container">
  310. <span class="pull-right">
  311. <a href="#top">Back to top</a>
  312. </span>
  313. <span>Generated by <strong>DocFX</strong></span>
  314. </div>
  315. </div>
  316. </footer>
  317. </div>
  318. <script type="text/javascript" src="../styles/docfx.vendor.js"></script>
  319. <script type="text/javascript" src="../styles/docfx.js"></script>
  320. <script type="text/javascript" src="../styles/main.js"></script>
  321. </body>
  322. </html>