Observable.Async.cs 228 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the Apache 2.0 License.
  3. // See the LICENSE file in the project root for more information.
  4. using System.Reactive.Concurrency;
  5. using System.Threading;
  6. using System.Threading.Tasks;
  7. namespace System.Reactive.Linq
  8. {
  9. public static partial class Observable
  10. {
  11. #region FromAsyncPattern
  12. #region Func
  13. /// <summary>
  14. /// Converts a Begin/End invoke function pair into an asynchronous function.
  15. /// </summary>
  16. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  17. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  18. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  19. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  20. /// <exception cref="ArgumentNullException"><paramref name="begin"/> or <paramref name="end"/> is null.</exception>
  21. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  22. #if PREFER_ASYNC
  23. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  24. #endif
  25. public static Func<IObservable<TResult>> FromAsyncPattern<TResult>(Func<AsyncCallback, object, IAsyncResult> begin, Func<IAsyncResult, TResult> end)
  26. {
  27. if (begin == null)
  28. {
  29. throw new ArgumentNullException(nameof(begin));
  30. }
  31. if (end == null)
  32. {
  33. throw new ArgumentNullException(nameof(end));
  34. }
  35. return s_impl.FromAsyncPattern(begin, end);
  36. }
  37. /// <summary>
  38. /// Converts a Begin/End invoke function pair into an asynchronous function.
  39. /// </summary>
  40. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  41. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  42. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  43. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  44. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  45. /// <exception cref="ArgumentNullException"><paramref name="begin"/> or <paramref name="end"/> is null.</exception>
  46. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  47. #if PREFER_ASYNC
  48. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  49. #endif
  50. public static Func<TArg1, IObservable<TResult>> FromAsyncPattern<TArg1, TResult>(Func<TArg1, AsyncCallback, object, IAsyncResult> begin, Func<IAsyncResult, TResult> end)
  51. {
  52. if (begin == null)
  53. {
  54. throw new ArgumentNullException(nameof(begin));
  55. }
  56. if (end == null)
  57. {
  58. throw new ArgumentNullException(nameof(end));
  59. }
  60. return s_impl.FromAsyncPattern(begin, end);
  61. }
  62. /// <summary>
  63. /// Converts a Begin/End invoke function pair into an asynchronous function.
  64. /// </summary>
  65. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  66. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  67. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  68. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  69. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  70. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  71. /// <exception cref="ArgumentNullException"><paramref name="begin"/> or <paramref name="end"/> is null.</exception>
  72. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  73. #if PREFER_ASYNC
  74. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  75. #endif
  76. public static Func<TArg1, TArg2, IObservable<TResult>> FromAsyncPattern<TArg1, TArg2, TResult>(Func<TArg1, TArg2, AsyncCallback, object, IAsyncResult> begin, Func<IAsyncResult, TResult> end)
  77. {
  78. if (begin == null)
  79. {
  80. throw new ArgumentNullException(nameof(begin));
  81. }
  82. if (end == null)
  83. {
  84. throw new ArgumentNullException(nameof(end));
  85. }
  86. return s_impl.FromAsyncPattern(begin, end);
  87. }
  88. /// <summary>
  89. /// Converts a Begin/End invoke function pair into an asynchronous function.
  90. /// </summary>
  91. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  92. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  93. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  94. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  95. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  96. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  97. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  98. /// <exception cref="ArgumentNullException"><paramref name="begin"/> or <paramref name="end"/> is null.</exception>
  99. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  100. #if PREFER_ASYNC
  101. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  102. #endif
  103. public static Func<TArg1, TArg2, TArg3, IObservable<TResult>> FromAsyncPattern<TArg1, TArg2, TArg3, TResult>(Func<TArg1, TArg2, TArg3, AsyncCallback, object, IAsyncResult> begin, Func<IAsyncResult, TResult> end)
  104. {
  105. if (begin == null)
  106. {
  107. throw new ArgumentNullException(nameof(begin));
  108. }
  109. if (end == null)
  110. {
  111. throw new ArgumentNullException(nameof(end));
  112. }
  113. return s_impl.FromAsyncPattern(begin, end);
  114. }
  115. /// <summary>
  116. /// Converts a Begin/End invoke function pair into an asynchronous function.
  117. /// </summary>
  118. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  119. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  120. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  121. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  122. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  123. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  124. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  125. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  126. /// <exception cref="ArgumentNullException"><paramref name="begin"/> or <paramref name="end"/> is null.</exception>
  127. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  128. #if PREFER_ASYNC
  129. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  130. #endif
  131. public static Func<TArg1, TArg2, TArg3, TArg4, IObservable<TResult>> FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TResult>(Func<TArg1, TArg2, TArg3, TArg4, AsyncCallback, object, IAsyncResult> begin, Func<IAsyncResult, TResult> end)
  132. {
  133. if (begin == null)
  134. {
  135. throw new ArgumentNullException(nameof(begin));
  136. }
  137. if (end == null)
  138. {
  139. throw new ArgumentNullException(nameof(end));
  140. }
  141. return s_impl.FromAsyncPattern(begin, end);
  142. }
  143. /// <summary>
  144. /// Converts a Begin/End invoke function pair into an asynchronous function.
  145. /// </summary>
  146. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  147. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  148. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  149. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  150. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  151. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  152. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  153. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  154. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  155. /// <exception cref="ArgumentNullException"><paramref name="begin"/> or <paramref name="end"/> is null.</exception>
  156. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  157. #if PREFER_ASYNC
  158. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  159. #endif
  160. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, IObservable<TResult>> FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TResult>(Func<TArg1, TArg2, TArg3, TArg4, TArg5, AsyncCallback, object, IAsyncResult> begin, Func<IAsyncResult, TResult> end)
  161. {
  162. if (begin == null)
  163. {
  164. throw new ArgumentNullException(nameof(begin));
  165. }
  166. if (end == null)
  167. {
  168. throw new ArgumentNullException(nameof(end));
  169. }
  170. return s_impl.FromAsyncPattern(begin, end);
  171. }
  172. /// <summary>
  173. /// Converts a Begin/End invoke function pair into an asynchronous function.
  174. /// </summary>
  175. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  176. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  177. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  178. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  179. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  180. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  181. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  182. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  183. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  184. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  185. /// <exception cref="ArgumentNullException"><paramref name="begin"/> or <paramref name="end"/> is null.</exception>
  186. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  187. #if PREFER_ASYNC
  188. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  189. #endif
  190. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, IObservable<TResult>> FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TResult>(Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, AsyncCallback, object, IAsyncResult> begin, Func<IAsyncResult, TResult> end)
  191. {
  192. if (begin == null)
  193. {
  194. throw new ArgumentNullException(nameof(begin));
  195. }
  196. if (end == null)
  197. {
  198. throw new ArgumentNullException(nameof(end));
  199. }
  200. return s_impl.FromAsyncPattern(begin, end);
  201. }
  202. /// <summary>
  203. /// Converts a Begin/End invoke function pair into an asynchronous function.
  204. /// </summary>
  205. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  206. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  207. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  208. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  209. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  210. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  211. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  212. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  213. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  214. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  215. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  216. /// <exception cref="ArgumentNullException"><paramref name="begin"/> or <paramref name="end"/> is null.</exception>
  217. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  218. #if PREFER_ASYNC
  219. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  220. #endif
  221. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, IObservable<TResult>> FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TResult>(Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, AsyncCallback, object, IAsyncResult> begin, Func<IAsyncResult, TResult> end)
  222. {
  223. if (begin == null)
  224. {
  225. throw new ArgumentNullException(nameof(begin));
  226. }
  227. if (end == null)
  228. {
  229. throw new ArgumentNullException(nameof(end));
  230. }
  231. return s_impl.FromAsyncPattern(begin, end);
  232. }
  233. /// <summary>
  234. /// Converts a Begin/End invoke function pair into an asynchronous function.
  235. /// </summary>
  236. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  237. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  238. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  239. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  240. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  241. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  242. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  243. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  244. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  245. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  246. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  247. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  248. /// <exception cref="ArgumentNullException"><paramref name="begin"/> or <paramref name="end"/> is null.</exception>
  249. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  250. #if PREFER_ASYNC
  251. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  252. #endif
  253. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, IObservable<TResult>> FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TResult>(Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, AsyncCallback, object, IAsyncResult> begin, Func<IAsyncResult, TResult> end)
  254. {
  255. if (begin == null)
  256. {
  257. throw new ArgumentNullException(nameof(begin));
  258. }
  259. if (end == null)
  260. {
  261. throw new ArgumentNullException(nameof(end));
  262. }
  263. return s_impl.FromAsyncPattern(begin, end);
  264. }
  265. /// <summary>
  266. /// Converts a Begin/End invoke function pair into an asynchronous function.
  267. /// </summary>
  268. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  269. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  270. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  271. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  272. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  273. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  274. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  275. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  276. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  277. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  278. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  279. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  280. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  281. /// <exception cref="ArgumentNullException"><paramref name="begin"/> or <paramref name="end"/> is null.</exception>
  282. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  283. #if PREFER_ASYNC
  284. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  285. #endif
  286. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, IObservable<TResult>> FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TResult>(Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, AsyncCallback, object, IAsyncResult> begin, Func<IAsyncResult, TResult> end)
  287. {
  288. if (begin == null)
  289. {
  290. throw new ArgumentNullException(nameof(begin));
  291. }
  292. if (end == null)
  293. {
  294. throw new ArgumentNullException(nameof(end));
  295. }
  296. return s_impl.FromAsyncPattern(begin, end);
  297. }
  298. /// <summary>
  299. /// Converts a Begin/End invoke function pair into an asynchronous function.
  300. /// </summary>
  301. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  302. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  303. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  304. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  305. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  306. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  307. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  308. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  309. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  310. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  311. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  312. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  313. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  314. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  315. /// <exception cref="ArgumentNullException"><paramref name="begin"/> or <paramref name="end"/> is null.</exception>
  316. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  317. #if PREFER_ASYNC
  318. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  319. #endif
  320. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, IObservable<TResult>> FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TResult>(Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, AsyncCallback, object, IAsyncResult> begin, Func<IAsyncResult, TResult> end)
  321. {
  322. if (begin == null)
  323. {
  324. throw new ArgumentNullException(nameof(begin));
  325. }
  326. if (end == null)
  327. {
  328. throw new ArgumentNullException(nameof(end));
  329. }
  330. return s_impl.FromAsyncPattern(begin, end);
  331. }
  332. /// <summary>
  333. /// Converts a Begin/End invoke function pair into an asynchronous function.
  334. /// </summary>
  335. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  336. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  337. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  338. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  339. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  340. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  341. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  342. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  343. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  344. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  345. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  346. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  347. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  348. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  349. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  350. /// <exception cref="ArgumentNullException"><paramref name="begin"/> or <paramref name="end"/> is null.</exception>
  351. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  352. #if PREFER_ASYNC
  353. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  354. #endif
  355. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, IObservable<TResult>> FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TResult>(Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, AsyncCallback, object, IAsyncResult> begin, Func<IAsyncResult, TResult> end)
  356. {
  357. if (begin == null)
  358. {
  359. throw new ArgumentNullException(nameof(begin));
  360. }
  361. if (end == null)
  362. {
  363. throw new ArgumentNullException(nameof(end));
  364. }
  365. return s_impl.FromAsyncPattern(begin, end);
  366. }
  367. /// <summary>
  368. /// Converts a Begin/End invoke function pair into an asynchronous function.
  369. /// </summary>
  370. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  371. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  372. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  373. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  374. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  375. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  376. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  377. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  378. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  379. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  380. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  381. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  382. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  383. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  384. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  385. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  386. /// <exception cref="ArgumentNullException"><paramref name="begin"/> or <paramref name="end"/> is null.</exception>
  387. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  388. #if PREFER_ASYNC
  389. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  390. #endif
  391. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, IObservable<TResult>> FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TResult>(Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, AsyncCallback, object, IAsyncResult> begin, Func<IAsyncResult, TResult> end)
  392. {
  393. if (begin == null)
  394. {
  395. throw new ArgumentNullException(nameof(begin));
  396. }
  397. if (end == null)
  398. {
  399. throw new ArgumentNullException(nameof(end));
  400. }
  401. return s_impl.FromAsyncPattern(begin, end);
  402. }
  403. /// <summary>
  404. /// Converts a Begin/End invoke function pair into an asynchronous function.
  405. /// </summary>
  406. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  407. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  408. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  409. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  410. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  411. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  412. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  413. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  414. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  415. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  416. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  417. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  418. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the begin delegate.</typeparam>
  419. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  420. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  421. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  422. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  423. /// <exception cref="ArgumentNullException"><paramref name="begin"/> or <paramref name="end"/> is null.</exception>
  424. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  425. #if PREFER_ASYNC
  426. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  427. #endif
  428. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, IObservable<TResult>> FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TResult>(Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, AsyncCallback, object, IAsyncResult> begin, Func<IAsyncResult, TResult> end)
  429. {
  430. if (begin == null)
  431. {
  432. throw new ArgumentNullException(nameof(begin));
  433. }
  434. if (end == null)
  435. {
  436. throw new ArgumentNullException(nameof(end));
  437. }
  438. return s_impl.FromAsyncPattern(begin, end);
  439. }
  440. /// <summary>
  441. /// Converts a Begin/End invoke function pair into an asynchronous function.
  442. /// </summary>
  443. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  444. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  445. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  446. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  447. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  448. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  449. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  450. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  451. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  452. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  453. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  454. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  455. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the begin delegate.</typeparam>
  456. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the begin delegate.</typeparam>
  457. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  458. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  459. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  460. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  461. /// <exception cref="ArgumentNullException"><paramref name="begin"/> or <paramref name="end"/> is null.</exception>
  462. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  463. #if PREFER_ASYNC
  464. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  465. #endif
  466. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, IObservable<TResult>> FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TResult>(Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, AsyncCallback, object, IAsyncResult> begin, Func<IAsyncResult, TResult> end)
  467. {
  468. if (begin == null)
  469. {
  470. throw new ArgumentNullException(nameof(begin));
  471. }
  472. if (end == null)
  473. {
  474. throw new ArgumentNullException(nameof(end));
  475. }
  476. return s_impl.FromAsyncPattern(begin, end);
  477. }
  478. #endregion
  479. #region Action
  480. /// <summary>
  481. /// Converts a Begin/End invoke function pair into an asynchronous function.
  482. /// </summary>
  483. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  484. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  485. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result (represented as a Unit value) as an observable sequence.</returns>
  486. /// <exception cref="ArgumentNullException"><paramref name="begin"/> or <paramref name="end"/> is null.</exception>
  487. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  488. #if PREFER_ASYNC
  489. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  490. #endif
  491. public static Func<IObservable<Unit>> FromAsyncPattern(Func<AsyncCallback, object, IAsyncResult> begin, Action<IAsyncResult> end)
  492. {
  493. if (begin == null)
  494. {
  495. throw new ArgumentNullException(nameof(begin));
  496. }
  497. if (end == null)
  498. {
  499. throw new ArgumentNullException(nameof(end));
  500. }
  501. return s_impl.FromAsyncPattern(begin, end);
  502. }
  503. /// <summary>
  504. /// Converts a Begin/End invoke function pair into an asynchronous function.
  505. /// </summary>
  506. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  507. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  508. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  509. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result (represented as a Unit value) as an observable sequence.</returns>
  510. /// <exception cref="ArgumentNullException"><paramref name="begin"/> or <paramref name="end"/> is null.</exception>
  511. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  512. #if PREFER_ASYNC
  513. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  514. #endif
  515. public static Func<TArg1, IObservable<Unit>> FromAsyncPattern<TArg1>(Func<TArg1, AsyncCallback, object, IAsyncResult> begin, Action<IAsyncResult> end)
  516. {
  517. if (begin == null)
  518. {
  519. throw new ArgumentNullException(nameof(begin));
  520. }
  521. if (end == null)
  522. {
  523. throw new ArgumentNullException(nameof(end));
  524. }
  525. return s_impl.FromAsyncPattern(begin, end);
  526. }
  527. /// <summary>
  528. /// Converts a Begin/End invoke function pair into an asynchronous function.
  529. /// </summary>
  530. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  531. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  532. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  533. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  534. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result (represented as a Unit value) as an observable sequence.</returns>
  535. /// <exception cref="ArgumentNullException"><paramref name="begin"/> or <paramref name="end"/> is null.</exception>
  536. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  537. #if PREFER_ASYNC
  538. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  539. #endif
  540. public static Func<TArg1, TArg2, IObservable<Unit>> FromAsyncPattern<TArg1, TArg2>(Func<TArg1, TArg2, AsyncCallback, object, IAsyncResult> begin, Action<IAsyncResult> end)
  541. {
  542. if (begin == null)
  543. {
  544. throw new ArgumentNullException(nameof(begin));
  545. }
  546. if (end == null)
  547. {
  548. throw new ArgumentNullException(nameof(end));
  549. }
  550. return s_impl.FromAsyncPattern(begin, end);
  551. }
  552. /// <summary>
  553. /// Converts a Begin/End invoke function pair into an asynchronous function.
  554. /// </summary>
  555. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  556. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  557. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  558. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  559. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  560. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result (represented as a Unit value) as an observable sequence.</returns>
  561. /// <exception cref="ArgumentNullException"><paramref name="begin"/> or <paramref name="end"/> is null.</exception>
  562. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  563. #if PREFER_ASYNC
  564. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  565. #endif
  566. public static Func<TArg1, TArg2, TArg3, IObservable<Unit>> FromAsyncPattern<TArg1, TArg2, TArg3>(Func<TArg1, TArg2, TArg3, AsyncCallback, object, IAsyncResult> begin, Action<IAsyncResult> end)
  567. {
  568. if (begin == null)
  569. {
  570. throw new ArgumentNullException(nameof(begin));
  571. }
  572. if (end == null)
  573. {
  574. throw new ArgumentNullException(nameof(end));
  575. }
  576. return s_impl.FromAsyncPattern(begin, end);
  577. }
  578. /// <summary>
  579. /// Converts a Begin/End invoke function pair into an asynchronous function.
  580. /// </summary>
  581. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  582. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  583. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  584. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  585. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  586. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  587. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result (represented as a Unit value) as an observable sequence.</returns>
  588. /// <exception cref="ArgumentNullException"><paramref name="begin"/> or <paramref name="end"/> is null.</exception>
  589. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  590. #if PREFER_ASYNC
  591. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  592. #endif
  593. public static Func<TArg1, TArg2, TArg3, TArg4, IObservable<Unit>> FromAsyncPattern<TArg1, TArg2, TArg3, TArg4>(Func<TArg1, TArg2, TArg3, TArg4, AsyncCallback, object, IAsyncResult> begin, Action<IAsyncResult> end)
  594. {
  595. if (begin == null)
  596. {
  597. throw new ArgumentNullException(nameof(begin));
  598. }
  599. if (end == null)
  600. {
  601. throw new ArgumentNullException(nameof(end));
  602. }
  603. return s_impl.FromAsyncPattern(begin, end);
  604. }
  605. /// <summary>
  606. /// Converts a Begin/End invoke function pair into an asynchronous function.
  607. /// </summary>
  608. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  609. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  610. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  611. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  612. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  613. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  614. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  615. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result (represented as a Unit value) as an observable sequence.</returns>
  616. /// <exception cref="ArgumentNullException"><paramref name="begin"/> or <paramref name="end"/> is null.</exception>
  617. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  618. #if PREFER_ASYNC
  619. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  620. #endif
  621. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, IObservable<Unit>> FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5>(Func<TArg1, TArg2, TArg3, TArg4, TArg5, AsyncCallback, object, IAsyncResult> begin, Action<IAsyncResult> end)
  622. {
  623. if (begin == null)
  624. {
  625. throw new ArgumentNullException(nameof(begin));
  626. }
  627. if (end == null)
  628. {
  629. throw new ArgumentNullException(nameof(end));
  630. }
  631. return s_impl.FromAsyncPattern(begin, end);
  632. }
  633. /// <summary>
  634. /// Converts a Begin/End invoke function pair into an asynchronous function.
  635. /// </summary>
  636. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  637. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  638. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  639. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  640. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  641. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  642. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  643. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  644. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result (represented as a Unit value) as an observable sequence.</returns>
  645. /// <exception cref="ArgumentNullException"><paramref name="begin"/> or <paramref name="end"/> is null.</exception>
  646. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  647. #if PREFER_ASYNC
  648. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  649. #endif
  650. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, IObservable<Unit>> FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6>(Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, AsyncCallback, object, IAsyncResult> begin, Action<IAsyncResult> end)
  651. {
  652. if (begin == null)
  653. {
  654. throw new ArgumentNullException(nameof(begin));
  655. }
  656. if (end == null)
  657. {
  658. throw new ArgumentNullException(nameof(end));
  659. }
  660. return s_impl.FromAsyncPattern(begin, end);
  661. }
  662. /// <summary>
  663. /// Converts a Begin/End invoke function pair into an asynchronous function.
  664. /// </summary>
  665. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  666. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  667. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  668. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  669. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  670. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  671. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  672. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  673. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  674. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result (represented as a Unit value) as an observable sequence.</returns>
  675. /// <exception cref="ArgumentNullException"><paramref name="begin"/> or <paramref name="end"/> is null.</exception>
  676. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  677. #if PREFER_ASYNC
  678. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  679. #endif
  680. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, IObservable<Unit>> FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7>(Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, AsyncCallback, object, IAsyncResult> begin, Action<IAsyncResult> end)
  681. {
  682. if (begin == null)
  683. {
  684. throw new ArgumentNullException(nameof(begin));
  685. }
  686. if (end == null)
  687. {
  688. throw new ArgumentNullException(nameof(end));
  689. }
  690. return s_impl.FromAsyncPattern(begin, end);
  691. }
  692. /// <summary>
  693. /// Converts a Begin/End invoke function pair into an asynchronous function.
  694. /// </summary>
  695. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  696. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  697. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  698. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  699. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  700. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  701. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  702. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  703. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  704. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  705. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result (represented as a Unit value) as an observable sequence.</returns>
  706. /// <exception cref="ArgumentNullException"><paramref name="begin"/> or <paramref name="end"/> is null.</exception>
  707. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  708. #if PREFER_ASYNC
  709. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  710. #endif
  711. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, IObservable<Unit>> FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8>(Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, AsyncCallback, object, IAsyncResult> begin, Action<IAsyncResult> end)
  712. {
  713. if (begin == null)
  714. {
  715. throw new ArgumentNullException(nameof(begin));
  716. }
  717. if (end == null)
  718. {
  719. throw new ArgumentNullException(nameof(end));
  720. }
  721. return s_impl.FromAsyncPattern(begin, end);
  722. }
  723. /// <summary>
  724. /// Converts a Begin/End invoke function pair into an asynchronous function.
  725. /// </summary>
  726. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  727. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  728. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  729. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  730. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  731. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  732. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  733. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  734. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  735. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  736. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  737. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result (represented as a Unit value) as an observable sequence.</returns>
  738. /// <exception cref="ArgumentNullException"><paramref name="begin"/> or <paramref name="end"/> is null.</exception>
  739. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  740. #if PREFER_ASYNC
  741. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  742. #endif
  743. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, IObservable<Unit>> FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9>(Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, AsyncCallback, object, IAsyncResult> begin, Action<IAsyncResult> end)
  744. {
  745. if (begin == null)
  746. {
  747. throw new ArgumentNullException(nameof(begin));
  748. }
  749. if (end == null)
  750. {
  751. throw new ArgumentNullException(nameof(end));
  752. }
  753. return s_impl.FromAsyncPattern(begin, end);
  754. }
  755. /// <summary>
  756. /// Converts a Begin/End invoke function pair into an asynchronous function.
  757. /// </summary>
  758. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  759. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  760. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  761. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  762. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  763. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  764. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  765. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  766. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  767. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  768. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  769. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  770. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result (represented as a Unit value) as an observable sequence.</returns>
  771. /// <exception cref="ArgumentNullException"><paramref name="begin"/> or <paramref name="end"/> is null.</exception>
  772. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  773. #if PREFER_ASYNC
  774. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  775. #endif
  776. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, IObservable<Unit>> FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10>(Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, AsyncCallback, object, IAsyncResult> begin, Action<IAsyncResult> end)
  777. {
  778. if (begin == null)
  779. {
  780. throw new ArgumentNullException(nameof(begin));
  781. }
  782. if (end == null)
  783. {
  784. throw new ArgumentNullException(nameof(end));
  785. }
  786. return s_impl.FromAsyncPattern(begin, end);
  787. }
  788. /// <summary>
  789. /// Converts a Begin/End invoke function pair into an asynchronous function.
  790. /// </summary>
  791. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  792. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  793. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  794. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  795. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  796. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  797. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  798. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  799. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  800. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  801. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  802. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  803. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  804. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result (represented as a Unit value) as an observable sequence.</returns>
  805. /// <exception cref="ArgumentNullException"><paramref name="begin"/> or <paramref name="end"/> is null.</exception>
  806. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  807. #if PREFER_ASYNC
  808. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  809. #endif
  810. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, IObservable<Unit>> FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11>(Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, AsyncCallback, object, IAsyncResult> begin, Action<IAsyncResult> end)
  811. {
  812. if (begin == null)
  813. {
  814. throw new ArgumentNullException(nameof(begin));
  815. }
  816. if (end == null)
  817. {
  818. throw new ArgumentNullException(nameof(end));
  819. }
  820. return s_impl.FromAsyncPattern(begin, end);
  821. }
  822. /// <summary>
  823. /// Converts a Begin/End invoke function pair into an asynchronous function.
  824. /// </summary>
  825. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  826. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  827. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  828. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  829. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  830. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  831. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  832. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  833. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  834. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  835. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  836. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  837. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  838. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  839. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result (represented as a Unit value) as an observable sequence.</returns>
  840. /// <exception cref="ArgumentNullException"><paramref name="begin"/> or <paramref name="end"/> is null.</exception>
  841. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  842. #if PREFER_ASYNC
  843. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  844. #endif
  845. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, IObservable<Unit>> FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12>(Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, AsyncCallback, object, IAsyncResult> begin, Action<IAsyncResult> end)
  846. {
  847. if (begin == null)
  848. {
  849. throw new ArgumentNullException(nameof(begin));
  850. }
  851. if (end == null)
  852. {
  853. throw new ArgumentNullException(nameof(end));
  854. }
  855. return s_impl.FromAsyncPattern(begin, end);
  856. }
  857. /// <summary>
  858. /// Converts a Begin/End invoke function pair into an asynchronous function.
  859. /// </summary>
  860. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  861. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  862. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  863. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  864. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  865. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  866. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  867. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  868. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  869. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  870. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  871. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  872. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the begin delegate.</typeparam>
  873. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  874. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  875. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result (represented as a Unit value) as an observable sequence.</returns>
  876. /// <exception cref="ArgumentNullException"><paramref name="begin"/> or <paramref name="end"/> is null.</exception>
  877. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  878. #if PREFER_ASYNC
  879. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  880. #endif
  881. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, IObservable<Unit>> FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13>(Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, AsyncCallback, object, IAsyncResult> begin, Action<IAsyncResult> end)
  882. {
  883. if (begin == null)
  884. {
  885. throw new ArgumentNullException(nameof(begin));
  886. }
  887. if (end == null)
  888. {
  889. throw new ArgumentNullException(nameof(end));
  890. }
  891. return s_impl.FromAsyncPattern(begin, end);
  892. }
  893. /// <summary>
  894. /// Converts a Begin/End invoke function pair into an asynchronous function.
  895. /// </summary>
  896. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  897. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  898. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  899. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  900. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  901. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  902. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  903. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  904. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  905. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  906. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  907. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  908. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the begin delegate.</typeparam>
  909. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the begin delegate.</typeparam>
  910. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  911. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  912. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result (represented as a Unit value) as an observable sequence.</returns>
  913. /// <exception cref="ArgumentNullException"><paramref name="begin"/> or <paramref name="end"/> is null.</exception>
  914. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  915. #if PREFER_ASYNC
  916. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  917. #endif
  918. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, IObservable<Unit>> FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14>(Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, AsyncCallback, object, IAsyncResult> begin, Action<IAsyncResult> end)
  919. {
  920. if (begin == null)
  921. {
  922. throw new ArgumentNullException(nameof(begin));
  923. }
  924. if (end == null)
  925. {
  926. throw new ArgumentNullException(nameof(end));
  927. }
  928. return s_impl.FromAsyncPattern(begin, end);
  929. }
  930. #endregion
  931. #endregion
  932. #region Start[Async]
  933. #region Func
  934. /// <summary>
  935. /// Invokes the specified function asynchronously, surfacing the result through an observable sequence.
  936. /// </summary>
  937. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  938. /// <param name="function">Function to run asynchronously.</param>
  939. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  940. /// <exception cref="ArgumentNullException"><paramref name="function"/> is null.</exception>
  941. /// <remarks>
  942. /// <list type="bullet">
  943. /// <item><description>The function is called immediately, not during the subscription of the resulting sequence.</description></item>
  944. /// <item><description>Multiple subscriptions to the resulting sequence can observe the function's result.</description></item>
  945. /// </list>
  946. /// </remarks>
  947. public static IObservable<TResult> Start<TResult>(Func<TResult> function)
  948. {
  949. if (function == null)
  950. {
  951. throw new ArgumentNullException(nameof(function));
  952. }
  953. return s_impl.Start(function);
  954. }
  955. /// <summary>
  956. /// Invokes the specified function asynchronously on the specified scheduler, surfacing the result through an observable sequence
  957. /// </summary>
  958. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  959. /// <param name="function">Function to run asynchronously.</param>
  960. /// <param name="scheduler">Scheduler to run the function on.</param>
  961. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  962. /// <exception cref="ArgumentNullException"><paramref name="function"/> or <paramref name="scheduler"/> is null.</exception>
  963. /// <remarks>
  964. /// <list type="bullet">
  965. /// <item><description>The function is called immediately, not during the subscription of the resulting sequence.</description></item>
  966. /// <item><description>Multiple subscriptions to the resulting sequence can observe the function's result.</description></item>
  967. /// </list>
  968. /// </remarks>
  969. public static IObservable<TResult> Start<TResult>(Func<TResult> function, IScheduler scheduler)
  970. {
  971. if (function == null)
  972. {
  973. throw new ArgumentNullException(nameof(function));
  974. }
  975. if (scheduler == null)
  976. {
  977. throw new ArgumentNullException(nameof(scheduler));
  978. }
  979. return s_impl.Start(function, scheduler);
  980. }
  981. /// <summary>
  982. /// Invokes the asynchronous function, surfacing the result through an observable sequence.
  983. /// </summary>
  984. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  985. /// <param name="functionAsync">Asynchronous function to run.</param>
  986. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  987. /// <exception cref="ArgumentNullException"><paramref name="functionAsync"/> is null.</exception>
  988. /// <remarks>
  989. /// <list type="bullet">
  990. /// <item><description>The function is started immediately, not during the subscription of the resulting sequence.</description></item>
  991. /// <item><description>Multiple subscriptions to the resulting sequence can observe the function's result.</description></item>
  992. /// </list>
  993. /// </remarks>
  994. public static IObservable<TResult> StartAsync<TResult>(Func<Task<TResult>> functionAsync)
  995. {
  996. if (functionAsync == null)
  997. {
  998. throw new ArgumentNullException(nameof(functionAsync));
  999. }
  1000. return s_impl.StartAsync(functionAsync);
  1001. }
  1002. /// <summary>
  1003. /// Invokes the asynchronous function, surfacing the result through an observable sequence.
  1004. /// </summary>
  1005. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  1006. /// <param name="functionAsync">Asynchronous function to run.</param>
  1007. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  1008. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  1009. /// <exception cref="ArgumentNullException"><paramref name="functionAsync"/> is null or <paramref name="scheduler"/> is null.</exception>
  1010. /// <remarks>
  1011. /// <list type="bullet">
  1012. /// <item><description>The function is started immediately, not during the subscription of the resulting sequence.</description></item>
  1013. /// <item><description>Multiple subscriptions to the resulting sequence can observe the function's result.</description></item>
  1014. /// </list>
  1015. /// </remarks>
  1016. public static IObservable<TResult> StartAsync<TResult>(Func<Task<TResult>> functionAsync, IScheduler scheduler)
  1017. {
  1018. if (functionAsync == null)
  1019. {
  1020. throw new ArgumentNullException(nameof(functionAsync));
  1021. }
  1022. if (scheduler == null)
  1023. {
  1024. throw new ArgumentNullException(nameof(scheduler));
  1025. }
  1026. return s_impl.StartAsync(functionAsync, scheduler);
  1027. }
  1028. /// <summary>
  1029. /// Invokes the asynchronous function, surfacing the result through an observable sequence.
  1030. /// The CancellationToken is shared by all subscriptions on the resulting observable sequence. See the remarks section for more information.
  1031. /// </summary>
  1032. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  1033. /// <param name="functionAsync">Asynchronous function to run.</param>
  1034. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  1035. /// <exception cref="ArgumentNullException"><paramref name="functionAsync"/> is null.</exception>
  1036. /// <remarks>
  1037. /// <list type="bullet">
  1038. /// <item><description>The function is started immediately, not during the subscription of the resulting sequence.</description></item>
  1039. /// <item><description>Multiple subscriptions to the resulting sequence can observe the function's result.</description></item>
  1040. /// <item><description>
  1041. /// If any subscription to the resulting sequence is disposed, the CancellationToken is set. The observer associated to the disposed
  1042. /// subscription won't see the TaskCanceledException, but other observers will. You can protect against this using the Catch operator.
  1043. /// Be careful when handing out the resulting sequence because of this behavior. The most common use is to have a single subscription
  1044. /// to the resulting sequence, which controls the CancellationToken state. Alternatively, you can control subscription behavior using
  1045. /// multicast operators.
  1046. /// </description></item>
  1047. /// </list>
  1048. /// </remarks>
  1049. public static IObservable<TResult> StartAsync<TResult>(Func<CancellationToken, Task<TResult>> functionAsync)
  1050. {
  1051. if (functionAsync == null)
  1052. {
  1053. throw new ArgumentNullException(nameof(functionAsync));
  1054. }
  1055. return s_impl.StartAsync(functionAsync);
  1056. }
  1057. /// <summary>
  1058. /// Invokes the asynchronous function, surfacing the result through an observable sequence.
  1059. /// The CancellationToken is shared by all subscriptions on the resulting observable sequence. See the remarks section for more information.
  1060. /// </summary>
  1061. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  1062. /// <param name="functionAsync">Asynchronous function to run.</param>
  1063. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  1064. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  1065. /// <exception cref="ArgumentNullException"><paramref name="functionAsync"/> is null or <paramref name="scheduler"/> is null.</exception>
  1066. /// <remarks>
  1067. /// <list type="bullet">
  1068. /// <item><description>The function is started immediately, not during the subscription of the resulting sequence.</description></item>
  1069. /// <item><description>Multiple subscriptions to the resulting sequence can observe the function's result.</description></item>
  1070. /// <item><description>
  1071. /// If any subscription to the resulting sequence is disposed, the CancellationToken is set. The observer associated to the disposed
  1072. /// subscription won't see the TaskCanceledException, but other observers will. You can protect against this using the Catch operator.
  1073. /// Be careful when handing out the resulting sequence because of this behavior. The most common use is to have a single subscription
  1074. /// to the resulting sequence, which controls the CancellationToken state. Alternatively, you can control subscription behavior using
  1075. /// multicast operators.
  1076. /// </description></item>
  1077. /// </list>
  1078. /// </remarks>
  1079. public static IObservable<TResult> StartAsync<TResult>(Func<CancellationToken, Task<TResult>> functionAsync, IScheduler scheduler)
  1080. {
  1081. if (functionAsync == null)
  1082. {
  1083. throw new ArgumentNullException(nameof(functionAsync));
  1084. }
  1085. if (scheduler == null)
  1086. {
  1087. throw new ArgumentNullException(nameof(scheduler));
  1088. }
  1089. return s_impl.StartAsync(functionAsync, scheduler);
  1090. }
  1091. #endregion
  1092. #region Action
  1093. /// <summary>
  1094. /// Invokes the action asynchronously, surfacing the result through an observable sequence.
  1095. /// </summary>
  1096. /// <param name="action">Action to run asynchronously.</param>
  1097. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  1098. /// <exception cref="ArgumentNullException"><paramref name="action"/> is null.</exception>
  1099. /// <remarks>
  1100. /// <list type="bullet">
  1101. /// <item><description>The action is called immediately, not during the subscription of the resulting sequence.</description></item>
  1102. /// <item><description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description></item>
  1103. /// </list>
  1104. /// </remarks>
  1105. public static IObservable<Unit> Start(Action action)
  1106. {
  1107. if (action == null)
  1108. {
  1109. throw new ArgumentNullException(nameof(action));
  1110. }
  1111. return s_impl.Start(action);
  1112. }
  1113. /// <summary>
  1114. /// Invokes the action asynchronously on the specified scheduler, surfacing the result through an observable sequence.
  1115. /// </summary>
  1116. /// <param name="action">Action to run asynchronously.</param>
  1117. /// <param name="scheduler">Scheduler to run the action on.</param>
  1118. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  1119. /// <exception cref="ArgumentNullException"><paramref name="action"/> or <paramref name="scheduler"/> is null.</exception>
  1120. /// <remarks>
  1121. /// <list type="bullet">
  1122. /// <item><description>The action is called immediately, not during the subscription of the resulting sequence.</description></item>
  1123. /// <item><description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description></item>
  1124. /// </list>
  1125. /// </remarks>
  1126. public static IObservable<Unit> Start(Action action, IScheduler scheduler)
  1127. {
  1128. if (action == null)
  1129. {
  1130. throw new ArgumentNullException(nameof(action));
  1131. }
  1132. if (scheduler == null)
  1133. {
  1134. throw new ArgumentNullException(nameof(scheduler));
  1135. }
  1136. return s_impl.Start(action, scheduler);
  1137. }
  1138. /// <summary>
  1139. /// Invokes the asynchronous action, surfacing the result through an observable sequence.
  1140. /// </summary>
  1141. /// <param name="actionAsync">Asynchronous action to run.</param>
  1142. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  1143. /// <exception cref="ArgumentNullException"><paramref name="actionAsync"/> is null.</exception>
  1144. /// <remarks>
  1145. /// <list type="bullet">
  1146. /// <item><description>The action is started immediately, not during the subscription of the resulting sequence.</description></item>
  1147. /// <item><description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description></item>
  1148. /// </list>
  1149. /// </remarks>
  1150. public static IObservable<Unit> StartAsync(Func<Task> actionAsync)
  1151. {
  1152. if (actionAsync == null)
  1153. {
  1154. throw new ArgumentNullException(nameof(actionAsync));
  1155. }
  1156. return s_impl.StartAsync(actionAsync);
  1157. }
  1158. /// <summary>
  1159. /// Invokes the asynchronous action, surfacing the result through an observable sequence.
  1160. /// </summary>
  1161. /// <param name="actionAsync">Asynchronous action to run.</param>
  1162. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  1163. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  1164. /// <exception cref="ArgumentNullException"><paramref name="actionAsync"/> is null or <paramref name="scheduler"/> is null.</exception>
  1165. /// <remarks>
  1166. /// <list type="bullet">
  1167. /// <item><description>The action is started immediately, not during the subscription of the resulting sequence.</description></item>
  1168. /// <item><description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description></item>
  1169. /// </list>
  1170. /// </remarks>
  1171. public static IObservable<Unit> StartAsync(Func<Task> actionAsync, IScheduler scheduler)
  1172. {
  1173. if (actionAsync == null)
  1174. {
  1175. throw new ArgumentNullException(nameof(actionAsync));
  1176. }
  1177. if (scheduler == null)
  1178. {
  1179. throw new ArgumentNullException(nameof(scheduler));
  1180. }
  1181. return s_impl.StartAsync(actionAsync, scheduler);
  1182. }
  1183. /// <summary>
  1184. /// Invokes the asynchronous action, surfacing the result through an observable sequence.
  1185. /// The CancellationToken is shared by all subscriptions on the resulting observable sequence. See the remarks section for more information.
  1186. /// </summary>
  1187. /// <param name="actionAsync">Asynchronous action to run.</param>
  1188. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  1189. /// <exception cref="ArgumentNullException"><paramref name="actionAsync"/> is null.</exception>
  1190. /// <remarks>
  1191. /// <list type="bullet">
  1192. /// <item><description>The action is started immediately, not during the subscription of the resulting sequence.</description></item>
  1193. /// <item><description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description></item>
  1194. /// <item><description>
  1195. /// If any subscription to the resulting sequence is disposed, the CancellationToken is set. The observer associated to the disposed
  1196. /// subscription won't see the TaskCanceledException, but other observers will. You can protect against this using the Catch operator.
  1197. /// Be careful when handing out the resulting sequence because of this behavior. The most common use is to have a single subscription
  1198. /// to the resulting sequence, which controls the CancellationToken state. Alternatively, you can control subscription behavior using
  1199. /// multicast operators.
  1200. /// </description></item>
  1201. /// </list>
  1202. /// </remarks>
  1203. public static IObservable<Unit> StartAsync(Func<CancellationToken, Task> actionAsync)
  1204. {
  1205. if (actionAsync == null)
  1206. {
  1207. throw new ArgumentNullException(nameof(actionAsync));
  1208. }
  1209. return s_impl.StartAsync(actionAsync);
  1210. }
  1211. /// <summary>
  1212. /// Invokes the asynchronous action, surfacing the result through an observable sequence.
  1213. /// The CancellationToken is shared by all subscriptions on the resulting observable sequence. See the remarks section for more information.
  1214. /// </summary>
  1215. /// <param name="actionAsync">Asynchronous action to run.</param>
  1216. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  1217. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  1218. /// <exception cref="ArgumentNullException"><paramref name="actionAsync"/> is null or <paramref name="scheduler"/> is null.</exception>
  1219. /// <remarks>
  1220. /// <list type="bullet">
  1221. /// <item><description>The action is started immediately, not during the subscription of the resulting sequence.</description></item>
  1222. /// <item><description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description></item>
  1223. /// <item><description>
  1224. /// If any subscription to the resulting sequence is disposed, the CancellationToken is set. The observer associated to the disposed
  1225. /// subscription won't see the TaskCanceledException, but other observers will. You can protect against this using the Catch operator.
  1226. /// Be careful when handing out the resulting sequence because of this behavior. The most common use is to have a single subscription
  1227. /// to the resulting sequence, which controls the CancellationToken state. Alternatively, you can control subscription behavior using
  1228. /// multicast operators.
  1229. /// </description></item>
  1230. /// </list>
  1231. /// </remarks>
  1232. public static IObservable<Unit> StartAsync(Func<CancellationToken, Task> actionAsync, IScheduler scheduler)
  1233. {
  1234. if (actionAsync == null)
  1235. {
  1236. throw new ArgumentNullException(nameof(actionAsync));
  1237. }
  1238. if (scheduler == null)
  1239. {
  1240. throw new ArgumentNullException(nameof(scheduler));
  1241. }
  1242. return s_impl.StartAsync(actionAsync, scheduler);
  1243. }
  1244. #endregion
  1245. #endregion
  1246. #region FromAsync
  1247. #region Func
  1248. /// <summary>
  1249. /// Converts to asynchronous function into an observable sequence. Each subscription to the resulting sequence causes the function to be started.
  1250. /// </summary>
  1251. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  1252. /// <param name="functionAsync">Asynchronous function to convert.</param>
  1253. /// <returns>An observable sequence exposing the result of invoking the function, or an exception.</returns>
  1254. /// <exception cref="ArgumentNullException"><paramref name="functionAsync"/> is null.</exception>
  1255. public static IObservable<TResult> FromAsync<TResult>(Func<Task<TResult>> functionAsync)
  1256. {
  1257. if (functionAsync == null)
  1258. {
  1259. throw new ArgumentNullException(nameof(functionAsync));
  1260. }
  1261. return s_impl.FromAsync(functionAsync);
  1262. }
  1263. /// <summary>
  1264. /// Converts to asynchronous function into an observable sequence. Each subscription to the resulting sequence causes the function to be started.
  1265. /// </summary>
  1266. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  1267. /// <param name="functionAsync">Asynchronous function to convert.</param>
  1268. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  1269. /// <returns>An observable sequence exposing the result of invoking the function, or an exception.</returns>
  1270. /// <exception cref="ArgumentNullException"><paramref name="functionAsync"/> is null or <paramref name="scheduler"/> is null.</exception>
  1271. public static IObservable<TResult> FromAsync<TResult>(Func<Task<TResult>> functionAsync, IScheduler scheduler)
  1272. {
  1273. if (functionAsync == null)
  1274. {
  1275. throw new ArgumentNullException(nameof(functionAsync));
  1276. }
  1277. if (scheduler == null)
  1278. {
  1279. throw new ArgumentNullException(nameof(scheduler));
  1280. }
  1281. return s_impl.FromAsync(functionAsync, scheduler);
  1282. }
  1283. /// <summary>
  1284. /// Converts to asynchronous function into an observable sequence. Each subscription to the resulting sequence causes the function to be started.
  1285. /// The CancellationToken passed to the asynchronous function is tied to the observable sequence's subscription that triggered the function's invocation and can be used for best-effort cancellation.
  1286. /// </summary>
  1287. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  1288. /// <param name="functionAsync">Asynchronous function to convert.</param>
  1289. /// <returns>An observable sequence exposing the result of invoking the function, or an exception.</returns>
  1290. /// <exception cref="ArgumentNullException"><paramref name="functionAsync"/> is null.</exception>
  1291. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous function will be signaled.</remarks>
  1292. public static IObservable<TResult> FromAsync<TResult>(Func<CancellationToken, Task<TResult>> functionAsync)
  1293. {
  1294. if (functionAsync == null)
  1295. {
  1296. throw new ArgumentNullException(nameof(functionAsync));
  1297. }
  1298. return s_impl.FromAsync(functionAsync);
  1299. }
  1300. /// <summary>
  1301. /// Converts to asynchronous function into an observable sequence. Each subscription to the resulting sequence causes the function to be started.
  1302. /// The CancellationToken passed to the asynchronous function is tied to the observable sequence's subscription that triggered the function's invocation and can be used for best-effort cancellation.
  1303. /// </summary>
  1304. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  1305. /// <param name="functionAsync">Asynchronous function to convert.</param>
  1306. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  1307. /// <returns>An observable sequence exposing the result of invoking the function, or an exception.</returns>
  1308. /// <exception cref="ArgumentNullException"><paramref name="functionAsync"/> is null or <paramref name="scheduler"/> is null.</exception>
  1309. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous function will be signaled.</remarks>
  1310. public static IObservable<TResult> FromAsync<TResult>(Func<CancellationToken, Task<TResult>> functionAsync, IScheduler scheduler)
  1311. {
  1312. if (functionAsync == null)
  1313. {
  1314. throw new ArgumentNullException(nameof(functionAsync));
  1315. }
  1316. if (scheduler == null)
  1317. {
  1318. throw new ArgumentNullException(nameof(scheduler));
  1319. }
  1320. return s_impl.FromAsync(functionAsync, scheduler);
  1321. }
  1322. #endregion
  1323. #region Action
  1324. /// <summary>
  1325. /// Converts to asynchronous action into an observable sequence. Each subscription to the resulting sequence causes the action to be started.
  1326. /// </summary>
  1327. /// <param name="actionAsync">Asynchronous action to convert.</param>
  1328. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  1329. /// <exception cref="ArgumentNullException"><paramref name="actionAsync"/> is null.</exception>
  1330. public static IObservable<Unit> FromAsync(Func<Task> actionAsync)
  1331. {
  1332. if (actionAsync == null)
  1333. {
  1334. throw new ArgumentNullException(nameof(actionAsync));
  1335. }
  1336. return s_impl.FromAsync(actionAsync);
  1337. }
  1338. /// <summary>
  1339. /// Converts to asynchronous action into an observable sequence. Each subscription to the resulting sequence causes the action to be started.
  1340. /// </summary>
  1341. /// <param name="actionAsync">Asynchronous action to convert.</param>
  1342. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  1343. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  1344. /// <exception cref="ArgumentNullException"><paramref name="actionAsync"/> is null or <paramref name="scheduler"/> is null.</exception>
  1345. public static IObservable<Unit> FromAsync(Func<Task> actionAsync, IScheduler scheduler)
  1346. {
  1347. if (actionAsync == null)
  1348. {
  1349. throw new ArgumentNullException(nameof(actionAsync));
  1350. }
  1351. if (scheduler == null)
  1352. {
  1353. throw new ArgumentNullException(nameof(scheduler));
  1354. }
  1355. return s_impl.FromAsync(actionAsync, scheduler);
  1356. }
  1357. /// <summary>
  1358. /// Converts to asynchronous action into an observable sequence. Each subscription to the resulting sequence causes the action to be started.
  1359. /// The CancellationToken passed to the asynchronous action is tied to the observable sequence's subscription that triggered the action's invocation and can be used for best-effort cancellation.
  1360. /// </summary>
  1361. /// <param name="actionAsync">Asynchronous action to convert.</param>
  1362. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  1363. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous function will be signaled.</remarks>
  1364. /// <exception cref="ArgumentNullException"><paramref name="actionAsync"/> is null.</exception>
  1365. public static IObservable<Unit> FromAsync(Func<CancellationToken, Task> actionAsync)
  1366. {
  1367. if (actionAsync == null)
  1368. {
  1369. throw new ArgumentNullException(nameof(actionAsync));
  1370. }
  1371. return s_impl.FromAsync(actionAsync);
  1372. }
  1373. /// <summary>
  1374. /// Converts to asynchronous action into an observable sequence. Each subscription to the resulting sequence causes the action to be started.
  1375. /// The CancellationToken passed to the asynchronous action is tied to the observable sequence's subscription that triggered the action's invocation and can be used for best-effort cancellation.
  1376. /// </summary>
  1377. /// <param name="actionAsync">Asynchronous action to convert.</param>
  1378. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  1379. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  1380. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous function will be signaled.</remarks>
  1381. /// <exception cref="ArgumentNullException"><paramref name="actionAsync"/> is null or <paramref name="scheduler"/> is null.</exception>
  1382. public static IObservable<Unit> FromAsync(Func<CancellationToken, Task> actionAsync, IScheduler scheduler)
  1383. {
  1384. if (actionAsync == null)
  1385. {
  1386. throw new ArgumentNullException(nameof(actionAsync));
  1387. }
  1388. if (scheduler == null)
  1389. {
  1390. throw new ArgumentNullException(nameof(scheduler));
  1391. }
  1392. return s_impl.FromAsync(actionAsync, scheduler);
  1393. }
  1394. #endregion
  1395. #endregion
  1396. #region ToAsync
  1397. #region Func
  1398. /// <summary>
  1399. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  1400. /// </summary>
  1401. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  1402. /// <param name="function">Function to convert to an asynchronous function.</param>
  1403. /// <returns>Asynchronous function.</returns>
  1404. /// <exception cref="ArgumentNullException"><paramref name="function"/> is null.</exception>
  1405. public static Func<IObservable<TResult>> ToAsync<TResult>(this Func<TResult> function)
  1406. {
  1407. if (function == null)
  1408. {
  1409. throw new ArgumentNullException(nameof(function));
  1410. }
  1411. return s_impl.ToAsync(function);
  1412. }
  1413. /// <summary>
  1414. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
  1415. /// </summary>
  1416. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  1417. /// <param name="function">Function to convert to an asynchronous function.</param>
  1418. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  1419. /// <returns>Asynchronous function.</returns>
  1420. /// <exception cref="ArgumentNullException"><paramref name="function"/> or <paramref name="scheduler"/> is null.</exception>
  1421. public static Func<IObservable<TResult>> ToAsync<TResult>(this Func<TResult> function, IScheduler scheduler)
  1422. {
  1423. if (function == null)
  1424. {
  1425. throw new ArgumentNullException(nameof(function));
  1426. }
  1427. if (scheduler == null)
  1428. {
  1429. throw new ArgumentNullException(nameof(scheduler));
  1430. }
  1431. return s_impl.ToAsync(function, scheduler);
  1432. }
  1433. /// <summary>
  1434. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  1435. /// </summary>
  1436. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  1437. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  1438. /// <param name="function">Function to convert to an asynchronous function.</param>
  1439. /// <returns>Asynchronous function.</returns>
  1440. /// <exception cref="ArgumentNullException"><paramref name="function"/> is null.</exception>
  1441. public static Func<TArg1, IObservable<TResult>> ToAsync<TArg1, TResult>(this Func<TArg1, TResult> function)
  1442. {
  1443. if (function == null)
  1444. {
  1445. throw new ArgumentNullException(nameof(function));
  1446. }
  1447. return s_impl.ToAsync(function);
  1448. }
  1449. /// <summary>
  1450. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
  1451. /// </summary>
  1452. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  1453. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  1454. /// <param name="function">Function to convert to an asynchronous function.</param>
  1455. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  1456. /// <returns>Asynchronous function.</returns>
  1457. /// <exception cref="ArgumentNullException"><paramref name="function"/> or <paramref name="scheduler"/> is null.</exception>
  1458. public static Func<TArg1, IObservable<TResult>> ToAsync<TArg1, TResult>(this Func<TArg1, TResult> function, IScheduler scheduler)
  1459. {
  1460. if (function == null)
  1461. {
  1462. throw new ArgumentNullException(nameof(function));
  1463. }
  1464. if (scheduler == null)
  1465. {
  1466. throw new ArgumentNullException(nameof(scheduler));
  1467. }
  1468. return s_impl.ToAsync(function, scheduler);
  1469. }
  1470. /// <summary>
  1471. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  1472. /// </summary>
  1473. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  1474. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  1475. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  1476. /// <param name="function">Function to convert to an asynchronous function.</param>
  1477. /// <returns>Asynchronous function.</returns>
  1478. /// <exception cref="ArgumentNullException"><paramref name="function"/> is null.</exception>
  1479. public static Func<TArg1, TArg2, IObservable<TResult>> ToAsync<TArg1, TArg2, TResult>(this Func<TArg1, TArg2, TResult> function)
  1480. {
  1481. if (function == null)
  1482. {
  1483. throw new ArgumentNullException(nameof(function));
  1484. }
  1485. return s_impl.ToAsync(function);
  1486. }
  1487. /// <summary>
  1488. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
  1489. /// </summary>
  1490. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  1491. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  1492. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  1493. /// <param name="function">Function to convert to an asynchronous function.</param>
  1494. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  1495. /// <returns>Asynchronous function.</returns>
  1496. /// <exception cref="ArgumentNullException"><paramref name="function"/> or <paramref name="scheduler"/> is null.</exception>
  1497. public static Func<TArg1, TArg2, IObservable<TResult>> ToAsync<TArg1, TArg2, TResult>(this Func<TArg1, TArg2, TResult> function, IScheduler scheduler)
  1498. {
  1499. if (function == null)
  1500. {
  1501. throw new ArgumentNullException(nameof(function));
  1502. }
  1503. if (scheduler == null)
  1504. {
  1505. throw new ArgumentNullException(nameof(scheduler));
  1506. }
  1507. return s_impl.ToAsync(function, scheduler);
  1508. }
  1509. /// <summary>
  1510. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  1511. /// </summary>
  1512. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  1513. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  1514. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  1515. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  1516. /// <param name="function">Function to convert to an asynchronous function.</param>
  1517. /// <returns>Asynchronous function.</returns>
  1518. /// <exception cref="ArgumentNullException"><paramref name="function"/> is null.</exception>
  1519. public static Func<TArg1, TArg2, TArg3, IObservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TResult>(this Func<TArg1, TArg2, TArg3, TResult> function)
  1520. {
  1521. if (function == null)
  1522. {
  1523. throw new ArgumentNullException(nameof(function));
  1524. }
  1525. return s_impl.ToAsync(function);
  1526. }
  1527. /// <summary>
  1528. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
  1529. /// </summary>
  1530. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  1531. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  1532. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  1533. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  1534. /// <param name="function">Function to convert to an asynchronous function.</param>
  1535. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  1536. /// <returns>Asynchronous function.</returns>
  1537. /// <exception cref="ArgumentNullException"><paramref name="function"/> or <paramref name="scheduler"/> is null.</exception>
  1538. public static Func<TArg1, TArg2, TArg3, IObservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TResult>(this Func<TArg1, TArg2, TArg3, TResult> function, IScheduler scheduler)
  1539. {
  1540. if (function == null)
  1541. {
  1542. throw new ArgumentNullException(nameof(function));
  1543. }
  1544. if (scheduler == null)
  1545. {
  1546. throw new ArgumentNullException(nameof(scheduler));
  1547. }
  1548. return s_impl.ToAsync(function, scheduler);
  1549. }
  1550. /// <summary>
  1551. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  1552. /// </summary>
  1553. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  1554. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  1555. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  1556. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  1557. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  1558. /// <param name="function">Function to convert to an asynchronous function.</param>
  1559. /// <returns>Asynchronous function.</returns>
  1560. /// <exception cref="ArgumentNullException"><paramref name="function"/> is null.</exception>
  1561. public static Func<TArg1, TArg2, TArg3, TArg4, IObservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TResult>(this Func<TArg1, TArg2, TArg3, TArg4, TResult> function)
  1562. {
  1563. if (function == null)
  1564. {
  1565. throw new ArgumentNullException(nameof(function));
  1566. }
  1567. return s_impl.ToAsync(function);
  1568. }
  1569. /// <summary>
  1570. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
  1571. /// </summary>
  1572. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  1573. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  1574. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  1575. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  1576. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  1577. /// <param name="function">Function to convert to an asynchronous function.</param>
  1578. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  1579. /// <returns>Asynchronous function.</returns>
  1580. /// <exception cref="ArgumentNullException"><paramref name="function"/> or <paramref name="scheduler"/> is null.</exception>
  1581. public static Func<TArg1, TArg2, TArg3, TArg4, IObservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TResult>(this Func<TArg1, TArg2, TArg3, TArg4, TResult> function, IScheduler scheduler)
  1582. {
  1583. if (function == null)
  1584. {
  1585. throw new ArgumentNullException(nameof(function));
  1586. }
  1587. if (scheduler == null)
  1588. {
  1589. throw new ArgumentNullException(nameof(scheduler));
  1590. }
  1591. return s_impl.ToAsync(function, scheduler);
  1592. }
  1593. /// <summary>
  1594. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  1595. /// </summary>
  1596. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  1597. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  1598. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  1599. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  1600. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  1601. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  1602. /// <param name="function">Function to convert to an asynchronous function.</param>
  1603. /// <returns>Asynchronous function.</returns>
  1604. /// <exception cref="ArgumentNullException"><paramref name="function"/> is null.</exception>
  1605. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, IObservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TResult>(this Func<TArg1, TArg2, TArg3, TArg4, TArg5, TResult> function)
  1606. {
  1607. if (function == null)
  1608. {
  1609. throw new ArgumentNullException(nameof(function));
  1610. }
  1611. return s_impl.ToAsync(function);
  1612. }
  1613. /// <summary>
  1614. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
  1615. /// </summary>
  1616. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  1617. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  1618. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  1619. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  1620. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  1621. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  1622. /// <param name="function">Function to convert to an asynchronous function.</param>
  1623. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  1624. /// <returns>Asynchronous function.</returns>
  1625. /// <exception cref="ArgumentNullException"><paramref name="function"/> or <paramref name="scheduler"/> is null.</exception>
  1626. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, IObservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TResult>(this Func<TArg1, TArg2, TArg3, TArg4, TArg5, TResult> function, IScheduler scheduler)
  1627. {
  1628. if (function == null)
  1629. {
  1630. throw new ArgumentNullException(nameof(function));
  1631. }
  1632. if (scheduler == null)
  1633. {
  1634. throw new ArgumentNullException(nameof(scheduler));
  1635. }
  1636. return s_impl.ToAsync(function, scheduler);
  1637. }
  1638. /// <summary>
  1639. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  1640. /// </summary>
  1641. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  1642. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  1643. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  1644. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  1645. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  1646. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  1647. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  1648. /// <param name="function">Function to convert to an asynchronous function.</param>
  1649. /// <returns>Asynchronous function.</returns>
  1650. /// <exception cref="ArgumentNullException"><paramref name="function"/> is null.</exception>
  1651. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, IObservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TResult>(this Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TResult> function)
  1652. {
  1653. if (function == null)
  1654. {
  1655. throw new ArgumentNullException(nameof(function));
  1656. }
  1657. return s_impl.ToAsync(function);
  1658. }
  1659. /// <summary>
  1660. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
  1661. /// </summary>
  1662. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  1663. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  1664. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  1665. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  1666. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  1667. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  1668. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  1669. /// <param name="function">Function to convert to an asynchronous function.</param>
  1670. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  1671. /// <returns>Asynchronous function.</returns>
  1672. /// <exception cref="ArgumentNullException"><paramref name="function"/> or <paramref name="scheduler"/> is null.</exception>
  1673. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, IObservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TResult>(this Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TResult> function, IScheduler scheduler)
  1674. {
  1675. if (function == null)
  1676. {
  1677. throw new ArgumentNullException(nameof(function));
  1678. }
  1679. if (scheduler == null)
  1680. {
  1681. throw new ArgumentNullException(nameof(scheduler));
  1682. }
  1683. return s_impl.ToAsync(function, scheduler);
  1684. }
  1685. /// <summary>
  1686. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  1687. /// </summary>
  1688. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  1689. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  1690. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  1691. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  1692. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  1693. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  1694. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  1695. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  1696. /// <param name="function">Function to convert to an asynchronous function.</param>
  1697. /// <returns>Asynchronous function.</returns>
  1698. /// <exception cref="ArgumentNullException"><paramref name="function"/> is null.</exception>
  1699. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, IObservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TResult>(this Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TResult> function)
  1700. {
  1701. if (function == null)
  1702. {
  1703. throw new ArgumentNullException(nameof(function));
  1704. }
  1705. return s_impl.ToAsync(function);
  1706. }
  1707. /// <summary>
  1708. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
  1709. /// </summary>
  1710. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  1711. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  1712. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  1713. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  1714. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  1715. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  1716. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  1717. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  1718. /// <param name="function">Function to convert to an asynchronous function.</param>
  1719. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  1720. /// <returns>Asynchronous function.</returns>
  1721. /// <exception cref="ArgumentNullException"><paramref name="function"/> or <paramref name="scheduler"/> is null.</exception>
  1722. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, IObservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TResult>(this Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TResult> function, IScheduler scheduler)
  1723. {
  1724. if (function == null)
  1725. {
  1726. throw new ArgumentNullException(nameof(function));
  1727. }
  1728. if (scheduler == null)
  1729. {
  1730. throw new ArgumentNullException(nameof(scheduler));
  1731. }
  1732. return s_impl.ToAsync(function, scheduler);
  1733. }
  1734. /// <summary>
  1735. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  1736. /// </summary>
  1737. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  1738. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  1739. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  1740. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  1741. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  1742. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  1743. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  1744. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  1745. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  1746. /// <param name="function">Function to convert to an asynchronous function.</param>
  1747. /// <returns>Asynchronous function.</returns>
  1748. /// <exception cref="ArgumentNullException"><paramref name="function"/> is null.</exception>
  1749. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, IObservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TResult>(this Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TResult> function)
  1750. {
  1751. if (function == null)
  1752. {
  1753. throw new ArgumentNullException(nameof(function));
  1754. }
  1755. return s_impl.ToAsync(function);
  1756. }
  1757. /// <summary>
  1758. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
  1759. /// </summary>
  1760. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  1761. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  1762. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  1763. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  1764. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  1765. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  1766. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  1767. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  1768. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  1769. /// <param name="function">Function to convert to an asynchronous function.</param>
  1770. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  1771. /// <returns>Asynchronous function.</returns>
  1772. /// <exception cref="ArgumentNullException"><paramref name="function"/> or <paramref name="scheduler"/> is null.</exception>
  1773. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, IObservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TResult>(this Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TResult> function, IScheduler scheduler)
  1774. {
  1775. if (function == null)
  1776. {
  1777. throw new ArgumentNullException(nameof(function));
  1778. }
  1779. if (scheduler == null)
  1780. {
  1781. throw new ArgumentNullException(nameof(scheduler));
  1782. }
  1783. return s_impl.ToAsync(function, scheduler);
  1784. }
  1785. /// <summary>
  1786. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  1787. /// </summary>
  1788. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  1789. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  1790. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  1791. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  1792. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  1793. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  1794. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  1795. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  1796. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  1797. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  1798. /// <param name="function">Function to convert to an asynchronous function.</param>
  1799. /// <returns>Asynchronous function.</returns>
  1800. /// <exception cref="ArgumentNullException"><paramref name="function"/> is null.</exception>
  1801. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, IObservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TResult>(this Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TResult> function)
  1802. {
  1803. if (function == null)
  1804. {
  1805. throw new ArgumentNullException(nameof(function));
  1806. }
  1807. return s_impl.ToAsync(function);
  1808. }
  1809. /// <summary>
  1810. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
  1811. /// </summary>
  1812. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  1813. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  1814. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  1815. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  1816. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  1817. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  1818. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  1819. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  1820. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  1821. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  1822. /// <param name="function">Function to convert to an asynchronous function.</param>
  1823. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  1824. /// <returns>Asynchronous function.</returns>
  1825. /// <exception cref="ArgumentNullException"><paramref name="function"/> or <paramref name="scheduler"/> is null.</exception>
  1826. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, IObservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TResult>(this Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TResult> function, IScheduler scheduler)
  1827. {
  1828. if (function == null)
  1829. {
  1830. throw new ArgumentNullException(nameof(function));
  1831. }
  1832. if (scheduler == null)
  1833. {
  1834. throw new ArgumentNullException(nameof(scheduler));
  1835. }
  1836. return s_impl.ToAsync(function, scheduler);
  1837. }
  1838. /// <summary>
  1839. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  1840. /// </summary>
  1841. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  1842. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  1843. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  1844. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  1845. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  1846. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  1847. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  1848. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  1849. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  1850. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  1851. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  1852. /// <param name="function">Function to convert to an asynchronous function.</param>
  1853. /// <returns>Asynchronous function.</returns>
  1854. /// <exception cref="ArgumentNullException"><paramref name="function"/> is null.</exception>
  1855. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, IObservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TResult>(this Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TResult> function)
  1856. {
  1857. if (function == null)
  1858. {
  1859. throw new ArgumentNullException(nameof(function));
  1860. }
  1861. return s_impl.ToAsync(function);
  1862. }
  1863. /// <summary>
  1864. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
  1865. /// </summary>
  1866. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  1867. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  1868. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  1869. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  1870. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  1871. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  1872. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  1873. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  1874. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  1875. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  1876. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  1877. /// <param name="function">Function to convert to an asynchronous function.</param>
  1878. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  1879. /// <returns>Asynchronous function.</returns>
  1880. /// <exception cref="ArgumentNullException"><paramref name="function"/> or <paramref name="scheduler"/> is null.</exception>
  1881. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, IObservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TResult>(this Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TResult> function, IScheduler scheduler)
  1882. {
  1883. if (function == null)
  1884. {
  1885. throw new ArgumentNullException(nameof(function));
  1886. }
  1887. if (scheduler == null)
  1888. {
  1889. throw new ArgumentNullException(nameof(scheduler));
  1890. }
  1891. return s_impl.ToAsync(function, scheduler);
  1892. }
  1893. /// <summary>
  1894. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  1895. /// </summary>
  1896. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  1897. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  1898. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  1899. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  1900. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  1901. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  1902. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  1903. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  1904. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  1905. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  1906. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  1907. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  1908. /// <param name="function">Function to convert to an asynchronous function.</param>
  1909. /// <returns>Asynchronous function.</returns>
  1910. /// <exception cref="ArgumentNullException"><paramref name="function"/> is null.</exception>
  1911. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, IObservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TResult>(this Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TResult> function)
  1912. {
  1913. if (function == null)
  1914. {
  1915. throw new ArgumentNullException(nameof(function));
  1916. }
  1917. return s_impl.ToAsync(function);
  1918. }
  1919. /// <summary>
  1920. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
  1921. /// </summary>
  1922. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  1923. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  1924. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  1925. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  1926. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  1927. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  1928. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  1929. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  1930. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  1931. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  1932. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  1933. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  1934. /// <param name="function">Function to convert to an asynchronous function.</param>
  1935. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  1936. /// <returns>Asynchronous function.</returns>
  1937. /// <exception cref="ArgumentNullException"><paramref name="function"/> or <paramref name="scheduler"/> is null.</exception>
  1938. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, IObservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TResult>(this Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TResult> function, IScheduler scheduler)
  1939. {
  1940. if (function == null)
  1941. {
  1942. throw new ArgumentNullException(nameof(function));
  1943. }
  1944. if (scheduler == null)
  1945. {
  1946. throw new ArgumentNullException(nameof(scheduler));
  1947. }
  1948. return s_impl.ToAsync(function, scheduler);
  1949. }
  1950. /// <summary>
  1951. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  1952. /// </summary>
  1953. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  1954. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  1955. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  1956. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  1957. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  1958. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  1959. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  1960. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  1961. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  1962. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  1963. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  1964. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  1965. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  1966. /// <param name="function">Function to convert to an asynchronous function.</param>
  1967. /// <returns>Asynchronous function.</returns>
  1968. /// <exception cref="ArgumentNullException"><paramref name="function"/> is null.</exception>
  1969. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, IObservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TResult>(this Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TResult> function)
  1970. {
  1971. if (function == null)
  1972. {
  1973. throw new ArgumentNullException(nameof(function));
  1974. }
  1975. return s_impl.ToAsync(function);
  1976. }
  1977. /// <summary>
  1978. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
  1979. /// </summary>
  1980. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  1981. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  1982. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  1983. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  1984. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  1985. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  1986. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  1987. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  1988. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  1989. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  1990. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  1991. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  1992. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  1993. /// <param name="function">Function to convert to an asynchronous function.</param>
  1994. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  1995. /// <returns>Asynchronous function.</returns>
  1996. /// <exception cref="ArgumentNullException"><paramref name="function"/> or <paramref name="scheduler"/> is null.</exception>
  1997. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, IObservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TResult>(this Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TResult> function, IScheduler scheduler)
  1998. {
  1999. if (function == null)
  2000. {
  2001. throw new ArgumentNullException(nameof(function));
  2002. }
  2003. if (scheduler == null)
  2004. {
  2005. throw new ArgumentNullException(nameof(scheduler));
  2006. }
  2007. return s_impl.ToAsync(function, scheduler);
  2008. }
  2009. /// <summary>
  2010. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  2011. /// </summary>
  2012. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  2013. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  2014. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  2015. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  2016. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  2017. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  2018. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  2019. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  2020. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  2021. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  2022. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  2023. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  2024. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  2025. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  2026. /// <param name="function">Function to convert to an asynchronous function.</param>
  2027. /// <returns>Asynchronous function.</returns>
  2028. /// <exception cref="ArgumentNullException"><paramref name="function"/> is null.</exception>
  2029. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, IObservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TResult>(this Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TResult> function)
  2030. {
  2031. if (function == null)
  2032. {
  2033. throw new ArgumentNullException(nameof(function));
  2034. }
  2035. return s_impl.ToAsync(function);
  2036. }
  2037. /// <summary>
  2038. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
  2039. /// </summary>
  2040. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  2041. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  2042. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  2043. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  2044. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  2045. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  2046. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  2047. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  2048. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  2049. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  2050. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  2051. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  2052. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  2053. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  2054. /// <param name="function">Function to convert to an asynchronous function.</param>
  2055. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  2056. /// <returns>Asynchronous function.</returns>
  2057. /// <exception cref="ArgumentNullException"><paramref name="function"/> or <paramref name="scheduler"/> is null.</exception>
  2058. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, IObservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TResult>(this Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TResult> function, IScheduler scheduler)
  2059. {
  2060. if (function == null)
  2061. {
  2062. throw new ArgumentNullException(nameof(function));
  2063. }
  2064. if (scheduler == null)
  2065. {
  2066. throw new ArgumentNullException(nameof(scheduler));
  2067. }
  2068. return s_impl.ToAsync(function, scheduler);
  2069. }
  2070. /// <summary>
  2071. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  2072. /// </summary>
  2073. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  2074. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  2075. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  2076. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  2077. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  2078. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  2079. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  2080. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  2081. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  2082. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  2083. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  2084. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  2085. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  2086. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  2087. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  2088. /// <param name="function">Function to convert to an asynchronous function.</param>
  2089. /// <returns>Asynchronous function.</returns>
  2090. /// <exception cref="ArgumentNullException"><paramref name="function"/> is null.</exception>
  2091. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, IObservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TResult>(this Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TResult> function)
  2092. {
  2093. if (function == null)
  2094. {
  2095. throw new ArgumentNullException(nameof(function));
  2096. }
  2097. return s_impl.ToAsync(function);
  2098. }
  2099. /// <summary>
  2100. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
  2101. /// </summary>
  2102. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  2103. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  2104. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  2105. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  2106. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  2107. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  2108. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  2109. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  2110. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  2111. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  2112. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  2113. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  2114. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  2115. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  2116. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  2117. /// <param name="function">Function to convert to an asynchronous function.</param>
  2118. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  2119. /// <returns>Asynchronous function.</returns>
  2120. /// <exception cref="ArgumentNullException"><paramref name="function"/> or <paramref name="scheduler"/> is null.</exception>
  2121. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, IObservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TResult>(this Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TResult> function, IScheduler scheduler)
  2122. {
  2123. if (function == null)
  2124. {
  2125. throw new ArgumentNullException(nameof(function));
  2126. }
  2127. if (scheduler == null)
  2128. {
  2129. throw new ArgumentNullException(nameof(scheduler));
  2130. }
  2131. return s_impl.ToAsync(function, scheduler);
  2132. }
  2133. /// <summary>
  2134. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  2135. /// </summary>
  2136. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  2137. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  2138. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  2139. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  2140. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  2141. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  2142. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  2143. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  2144. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  2145. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  2146. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  2147. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  2148. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  2149. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  2150. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the function.</typeparam>
  2151. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  2152. /// <param name="function">Function to convert to an asynchronous function.</param>
  2153. /// <returns>Asynchronous function.</returns>
  2154. /// <exception cref="ArgumentNullException"><paramref name="function"/> is null.</exception>
  2155. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, IObservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TResult>(this Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TResult> function)
  2156. {
  2157. if (function == null)
  2158. {
  2159. throw new ArgumentNullException(nameof(function));
  2160. }
  2161. return s_impl.ToAsync(function);
  2162. }
  2163. /// <summary>
  2164. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
  2165. /// </summary>
  2166. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  2167. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  2168. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  2169. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  2170. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  2171. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  2172. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  2173. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  2174. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  2175. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  2176. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  2177. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  2178. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  2179. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  2180. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the function.</typeparam>
  2181. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  2182. /// <param name="function">Function to convert to an asynchronous function.</param>
  2183. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  2184. /// <returns>Asynchronous function.</returns>
  2185. /// <exception cref="ArgumentNullException"><paramref name="function"/> or <paramref name="scheduler"/> is null.</exception>
  2186. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, IObservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TResult>(this Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TResult> function, IScheduler scheduler)
  2187. {
  2188. if (function == null)
  2189. {
  2190. throw new ArgumentNullException(nameof(function));
  2191. }
  2192. if (scheduler == null)
  2193. {
  2194. throw new ArgumentNullException(nameof(scheduler));
  2195. }
  2196. return s_impl.ToAsync(function, scheduler);
  2197. }
  2198. /// <summary>
  2199. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  2200. /// </summary>
  2201. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  2202. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  2203. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  2204. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  2205. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  2206. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  2207. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  2208. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  2209. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  2210. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  2211. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  2212. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  2213. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  2214. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  2215. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the function.</typeparam>
  2216. /// <typeparam name="TArg16">The type of the sixteenth argument passed to the function.</typeparam>
  2217. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  2218. /// <param name="function">Function to convert to an asynchronous function.</param>
  2219. /// <returns>Asynchronous function.</returns>
  2220. /// <exception cref="ArgumentNullException"><paramref name="function"/> is null.</exception>
  2221. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TArg16, IObservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TArg16, TResult>(this Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TArg16, TResult> function)
  2222. {
  2223. if (function == null)
  2224. {
  2225. throw new ArgumentNullException(nameof(function));
  2226. }
  2227. return s_impl.ToAsync(function);
  2228. }
  2229. /// <summary>
  2230. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
  2231. /// </summary>
  2232. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  2233. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  2234. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  2235. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  2236. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  2237. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  2238. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  2239. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  2240. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  2241. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  2242. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  2243. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  2244. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  2245. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  2246. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the function.</typeparam>
  2247. /// <typeparam name="TArg16">The type of the sixteenth argument passed to the function.</typeparam>
  2248. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  2249. /// <param name="function">Function to convert to an asynchronous function.</param>
  2250. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  2251. /// <returns>Asynchronous function.</returns>
  2252. /// <exception cref="ArgumentNullException"><paramref name="function"/> or <paramref name="scheduler"/> is null.</exception>
  2253. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TArg16, IObservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TArg16, TResult>(this Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TArg16, TResult> function, IScheduler scheduler)
  2254. {
  2255. if (function == null)
  2256. {
  2257. throw new ArgumentNullException(nameof(function));
  2258. }
  2259. if (scheduler == null)
  2260. {
  2261. throw new ArgumentNullException(nameof(scheduler));
  2262. }
  2263. return s_impl.ToAsync(function, scheduler);
  2264. }
  2265. #endregion
  2266. #region Action
  2267. /// <summary>
  2268. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the specified scheduler.
  2269. /// </summary>
  2270. /// <param name="action">Action to convert to an asynchronous action.</param>
  2271. /// <returns>Asynchronous action.</returns>
  2272. /// <exception cref="ArgumentNullException"><paramref name="action"/> is null.</exception>
  2273. public static Func<IObservable<Unit>> ToAsync(this Action action)
  2274. {
  2275. if (action == null)
  2276. {
  2277. throw new ArgumentNullException(nameof(action));
  2278. }
  2279. return s_impl.ToAsync(action);
  2280. }
  2281. /// <summary>
  2282. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the specified scheduler.
  2283. /// </summary>
  2284. /// <param name="action">Action to convert to an asynchronous action.</param>
  2285. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  2286. /// <returns>Asynchronous action.</returns>
  2287. /// <exception cref="ArgumentNullException"><paramref name="action"/> or <paramref name="scheduler"/> is null.</exception>
  2288. public static Func<IObservable<Unit>> ToAsync(this Action action, IScheduler scheduler)
  2289. {
  2290. if (action == null)
  2291. {
  2292. throw new ArgumentNullException(nameof(action));
  2293. }
  2294. if (scheduler == null)
  2295. {
  2296. throw new ArgumentNullException(nameof(scheduler));
  2297. }
  2298. return s_impl.ToAsync(action, scheduler);
  2299. }
  2300. /// <summary>
  2301. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the default scheduler.
  2302. /// </summary>
  2303. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  2304. /// <param name="action">Action to convert to an asynchronous action.</param>
  2305. /// <returns>Asynchronous action.</returns>
  2306. /// <exception cref="ArgumentNullException"><paramref name="action"/> is null.</exception>
  2307. public static Func<TArg1, IObservable<Unit>> ToAsync<TArg1>(this Action<TArg1> action)
  2308. {
  2309. if (action == null)
  2310. {
  2311. throw new ArgumentNullException(nameof(action));
  2312. }
  2313. return s_impl.ToAsync(action);
  2314. }
  2315. /// <summary>
  2316. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the specified scheduler.
  2317. /// </summary>
  2318. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  2319. /// <param name="action">Action to convert to an asynchronous action.</param>
  2320. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  2321. /// <returns>Asynchronous action.</returns>
  2322. /// <exception cref="ArgumentNullException"><paramref name="action"/> or <paramref name="scheduler"/> is null.</exception>
  2323. public static Func<TArg1, IObservable<Unit>> ToAsync<TArg1>(this Action<TArg1> action, IScheduler scheduler)
  2324. {
  2325. if (action == null)
  2326. {
  2327. throw new ArgumentNullException(nameof(action));
  2328. }
  2329. if (scheduler == null)
  2330. {
  2331. throw new ArgumentNullException(nameof(scheduler));
  2332. }
  2333. return s_impl.ToAsync(action, scheduler);
  2334. }
  2335. /// <summary>
  2336. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the default scheduler.
  2337. /// </summary>
  2338. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  2339. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  2340. /// <param name="action">Action to convert to an asynchronous action.</param>
  2341. /// <returns>Asynchronous action.</returns>
  2342. /// <exception cref="ArgumentNullException"><paramref name="action"/> is null.</exception>
  2343. public static Func<TArg1, TArg2, IObservable<Unit>> ToAsync<TArg1, TArg2>(this Action<TArg1, TArg2> action)
  2344. {
  2345. if (action == null)
  2346. {
  2347. throw new ArgumentNullException(nameof(action));
  2348. }
  2349. return s_impl.ToAsync(action);
  2350. }
  2351. /// <summary>
  2352. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the specified scheduler.
  2353. /// </summary>
  2354. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  2355. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  2356. /// <param name="action">Action to convert to an asynchronous action.</param>
  2357. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  2358. /// <returns>Asynchronous action.</returns>
  2359. /// <exception cref="ArgumentNullException"><paramref name="action"/> or <paramref name="scheduler"/> is null.</exception>
  2360. public static Func<TArg1, TArg2, IObservable<Unit>> ToAsync<TArg1, TArg2>(this Action<TArg1, TArg2> action, IScheduler scheduler)
  2361. {
  2362. if (action == null)
  2363. {
  2364. throw new ArgumentNullException(nameof(action));
  2365. }
  2366. if (scheduler == null)
  2367. {
  2368. throw new ArgumentNullException(nameof(scheduler));
  2369. }
  2370. return s_impl.ToAsync(action, scheduler);
  2371. }
  2372. /// <summary>
  2373. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the default scheduler.
  2374. /// </summary>
  2375. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  2376. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  2377. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  2378. /// <param name="action">Action to convert to an asynchronous action.</param>
  2379. /// <returns>Asynchronous action.</returns>
  2380. /// <exception cref="ArgumentNullException"><paramref name="action"/> is null.</exception>
  2381. public static Func<TArg1, TArg2, TArg3, IObservable<Unit>> ToAsync<TArg1, TArg2, TArg3>(this Action<TArg1, TArg2, TArg3> action)
  2382. {
  2383. if (action == null)
  2384. {
  2385. throw new ArgumentNullException(nameof(action));
  2386. }
  2387. return s_impl.ToAsync(action);
  2388. }
  2389. /// <summary>
  2390. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the specified scheduler.
  2391. /// </summary>
  2392. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  2393. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  2394. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  2395. /// <param name="action">Action to convert to an asynchronous action.</param>
  2396. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  2397. /// <returns>Asynchronous action.</returns>
  2398. /// <exception cref="ArgumentNullException"><paramref name="action"/> or <paramref name="scheduler"/> is null.</exception>
  2399. public static Func<TArg1, TArg2, TArg3, IObservable<Unit>> ToAsync<TArg1, TArg2, TArg3>(this Action<TArg1, TArg2, TArg3> action, IScheduler scheduler)
  2400. {
  2401. if (action == null)
  2402. {
  2403. throw new ArgumentNullException(nameof(action));
  2404. }
  2405. if (scheduler == null)
  2406. {
  2407. throw new ArgumentNullException(nameof(scheduler));
  2408. }
  2409. return s_impl.ToAsync(action, scheduler);
  2410. }
  2411. /// <summary>
  2412. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the default scheduler.
  2413. /// </summary>
  2414. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  2415. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  2416. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  2417. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  2418. /// <param name="action">Action to convert to an asynchronous action.</param>
  2419. /// <returns>Asynchronous action.</returns>
  2420. /// <exception cref="ArgumentNullException"><paramref name="action"/> is null.</exception>
  2421. public static Func<TArg1, TArg2, TArg3, TArg4, IObservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4>(this Action<TArg1, TArg2, TArg3, TArg4> action)
  2422. {
  2423. if (action == null)
  2424. {
  2425. throw new ArgumentNullException(nameof(action));
  2426. }
  2427. return s_impl.ToAsync(action);
  2428. }
  2429. /// <summary>
  2430. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the specified scheduler.
  2431. /// </summary>
  2432. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  2433. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  2434. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  2435. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  2436. /// <param name="action">Action to convert to an asynchronous action.</param>
  2437. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  2438. /// <returns>Asynchronous action.</returns>
  2439. /// <exception cref="ArgumentNullException"><paramref name="action"/> or <paramref name="scheduler"/> is null.</exception>
  2440. public static Func<TArg1, TArg2, TArg3, TArg4, IObservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4>(this Action<TArg1, TArg2, TArg3, TArg4> action, IScheduler scheduler)
  2441. {
  2442. if (action == null)
  2443. {
  2444. throw new ArgumentNullException(nameof(action));
  2445. }
  2446. if (scheduler == null)
  2447. {
  2448. throw new ArgumentNullException(nameof(scheduler));
  2449. }
  2450. return s_impl.ToAsync(action, scheduler);
  2451. }
  2452. /// <summary>
  2453. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the default scheduler.
  2454. /// </summary>
  2455. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  2456. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  2457. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  2458. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  2459. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  2460. /// <param name="action">Action to convert to an asynchronous action.</param>
  2461. /// <returns>Asynchronous action.</returns>
  2462. /// <exception cref="ArgumentNullException"><paramref name="action"/> is null.</exception>
  2463. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, IObservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5>(this Action<TArg1, TArg2, TArg3, TArg4, TArg5> action)
  2464. {
  2465. if (action == null)
  2466. {
  2467. throw new ArgumentNullException(nameof(action));
  2468. }
  2469. return s_impl.ToAsync(action);
  2470. }
  2471. /// <summary>
  2472. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the specified scheduler.
  2473. /// </summary>
  2474. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  2475. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  2476. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  2477. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  2478. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  2479. /// <param name="action">Action to convert to an asynchronous action.</param>
  2480. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  2481. /// <returns>Asynchronous action.</returns>
  2482. /// <exception cref="ArgumentNullException"><paramref name="action"/> or <paramref name="scheduler"/> is null.</exception>
  2483. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, IObservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5>(this Action<TArg1, TArg2, TArg3, TArg4, TArg5> action, IScheduler scheduler)
  2484. {
  2485. if (action == null)
  2486. {
  2487. throw new ArgumentNullException(nameof(action));
  2488. }
  2489. if (scheduler == null)
  2490. {
  2491. throw new ArgumentNullException(nameof(scheduler));
  2492. }
  2493. return s_impl.ToAsync(action, scheduler);
  2494. }
  2495. /// <summary>
  2496. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the default scheduler.
  2497. /// </summary>
  2498. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  2499. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  2500. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  2501. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  2502. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  2503. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  2504. /// <param name="action">Action to convert to an asynchronous action.</param>
  2505. /// <returns>Asynchronous action.</returns>
  2506. /// <exception cref="ArgumentNullException"><paramref name="action"/> is null.</exception>
  2507. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, IObservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6>(this Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6> action)
  2508. {
  2509. if (action == null)
  2510. {
  2511. throw new ArgumentNullException(nameof(action));
  2512. }
  2513. return s_impl.ToAsync(action);
  2514. }
  2515. /// <summary>
  2516. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the specified scheduler.
  2517. /// </summary>
  2518. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  2519. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  2520. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  2521. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  2522. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  2523. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  2524. /// <param name="action">Action to convert to an asynchronous action.</param>
  2525. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  2526. /// <returns>Asynchronous action.</returns>
  2527. /// <exception cref="ArgumentNullException"><paramref name="action"/> or <paramref name="scheduler"/> is null.</exception>
  2528. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, IObservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6>(this Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6> action, IScheduler scheduler)
  2529. {
  2530. if (action == null)
  2531. {
  2532. throw new ArgumentNullException(nameof(action));
  2533. }
  2534. if (scheduler == null)
  2535. {
  2536. throw new ArgumentNullException(nameof(scheduler));
  2537. }
  2538. return s_impl.ToAsync(action, scheduler);
  2539. }
  2540. /// <summary>
  2541. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the default scheduler.
  2542. /// </summary>
  2543. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  2544. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  2545. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  2546. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  2547. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  2548. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  2549. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  2550. /// <param name="action">Action to convert to an asynchronous action.</param>
  2551. /// <returns>Asynchronous action.</returns>
  2552. /// <exception cref="ArgumentNullException"><paramref name="action"/> is null.</exception>
  2553. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, IObservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7>(this Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7> action)
  2554. {
  2555. if (action == null)
  2556. {
  2557. throw new ArgumentNullException(nameof(action));
  2558. }
  2559. return s_impl.ToAsync(action);
  2560. }
  2561. /// <summary>
  2562. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the specified scheduler.
  2563. /// </summary>
  2564. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  2565. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  2566. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  2567. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  2568. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  2569. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  2570. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  2571. /// <param name="action">Action to convert to an asynchronous action.</param>
  2572. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  2573. /// <returns>Asynchronous action.</returns>
  2574. /// <exception cref="ArgumentNullException"><paramref name="action"/> or <paramref name="scheduler"/> is null.</exception>
  2575. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, IObservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7>(this Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7> action, IScheduler scheduler)
  2576. {
  2577. if (action == null)
  2578. {
  2579. throw new ArgumentNullException(nameof(action));
  2580. }
  2581. if (scheduler == null)
  2582. {
  2583. throw new ArgumentNullException(nameof(scheduler));
  2584. }
  2585. return s_impl.ToAsync(action, scheduler);
  2586. }
  2587. /// <summary>
  2588. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the default scheduler.
  2589. /// </summary>
  2590. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  2591. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  2592. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  2593. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  2594. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  2595. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  2596. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  2597. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  2598. /// <param name="action">Action to convert to an asynchronous action.</param>
  2599. /// <returns>Asynchronous action.</returns>
  2600. /// <exception cref="ArgumentNullException"><paramref name="action"/> is null.</exception>
  2601. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, IObservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8>(this Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8> action)
  2602. {
  2603. if (action == null)
  2604. {
  2605. throw new ArgumentNullException(nameof(action));
  2606. }
  2607. return s_impl.ToAsync(action);
  2608. }
  2609. /// <summary>
  2610. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the specified scheduler.
  2611. /// </summary>
  2612. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  2613. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  2614. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  2615. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  2616. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  2617. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  2618. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  2619. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  2620. /// <param name="action">Action to convert to an asynchronous action.</param>
  2621. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  2622. /// <returns>Asynchronous action.</returns>
  2623. /// <exception cref="ArgumentNullException"><paramref name="action"/> or <paramref name="scheduler"/> is null.</exception>
  2624. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, IObservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8>(this Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8> action, IScheduler scheduler)
  2625. {
  2626. if (action == null)
  2627. {
  2628. throw new ArgumentNullException(nameof(action));
  2629. }
  2630. if (scheduler == null)
  2631. {
  2632. throw new ArgumentNullException(nameof(scheduler));
  2633. }
  2634. return s_impl.ToAsync(action, scheduler);
  2635. }
  2636. /// <summary>
  2637. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the default scheduler.
  2638. /// </summary>
  2639. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  2640. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  2641. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  2642. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  2643. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  2644. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  2645. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  2646. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  2647. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  2648. /// <param name="action">Action to convert to an asynchronous action.</param>
  2649. /// <returns>Asynchronous action.</returns>
  2650. /// <exception cref="ArgumentNullException"><paramref name="action"/> is null.</exception>
  2651. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, IObservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9>(this Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9> action)
  2652. {
  2653. if (action == null)
  2654. {
  2655. throw new ArgumentNullException(nameof(action));
  2656. }
  2657. return s_impl.ToAsync(action);
  2658. }
  2659. /// <summary>
  2660. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the specified scheduler.
  2661. /// </summary>
  2662. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  2663. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  2664. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  2665. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  2666. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  2667. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  2668. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  2669. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  2670. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  2671. /// <param name="action">Action to convert to an asynchronous action.</param>
  2672. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  2673. /// <returns>Asynchronous action.</returns>
  2674. /// <exception cref="ArgumentNullException"><paramref name="action"/> or <paramref name="scheduler"/> is null.</exception>
  2675. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, IObservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9>(this Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9> action, IScheduler scheduler)
  2676. {
  2677. if (action == null)
  2678. {
  2679. throw new ArgumentNullException(nameof(action));
  2680. }
  2681. if (scheduler == null)
  2682. {
  2683. throw new ArgumentNullException(nameof(scheduler));
  2684. }
  2685. return s_impl.ToAsync(action, scheduler);
  2686. }
  2687. /// <summary>
  2688. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the default scheduler.
  2689. /// </summary>
  2690. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  2691. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  2692. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  2693. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  2694. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  2695. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  2696. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  2697. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  2698. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  2699. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  2700. /// <param name="action">Action to convert to an asynchronous action.</param>
  2701. /// <returns>Asynchronous action.</returns>
  2702. /// <exception cref="ArgumentNullException"><paramref name="action"/> is null.</exception>
  2703. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, IObservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10>(this Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10> action)
  2704. {
  2705. if (action == null)
  2706. {
  2707. throw new ArgumentNullException(nameof(action));
  2708. }
  2709. return s_impl.ToAsync(action);
  2710. }
  2711. /// <summary>
  2712. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the specified scheduler.
  2713. /// </summary>
  2714. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  2715. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  2716. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  2717. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  2718. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  2719. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  2720. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  2721. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  2722. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  2723. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  2724. /// <param name="action">Action to convert to an asynchronous action.</param>
  2725. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  2726. /// <returns>Asynchronous action.</returns>
  2727. /// <exception cref="ArgumentNullException"><paramref name="action"/> or <paramref name="scheduler"/> is null.</exception>
  2728. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, IObservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10>(this Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10> action, IScheduler scheduler)
  2729. {
  2730. if (action == null)
  2731. {
  2732. throw new ArgumentNullException(nameof(action));
  2733. }
  2734. if (scheduler == null)
  2735. {
  2736. throw new ArgumentNullException(nameof(scheduler));
  2737. }
  2738. return s_impl.ToAsync(action, scheduler);
  2739. }
  2740. /// <summary>
  2741. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the default scheduler.
  2742. /// </summary>
  2743. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  2744. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  2745. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  2746. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  2747. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  2748. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  2749. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  2750. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  2751. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  2752. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  2753. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  2754. /// <param name="action">Action to convert to an asynchronous action.</param>
  2755. /// <returns>Asynchronous action.</returns>
  2756. /// <exception cref="ArgumentNullException"><paramref name="action"/> is null.</exception>
  2757. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, IObservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11>(this Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11> action)
  2758. {
  2759. if (action == null)
  2760. {
  2761. throw new ArgumentNullException(nameof(action));
  2762. }
  2763. return s_impl.ToAsync(action);
  2764. }
  2765. /// <summary>
  2766. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the specified scheduler.
  2767. /// </summary>
  2768. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  2769. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  2770. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  2771. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  2772. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  2773. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  2774. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  2775. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  2776. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  2777. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  2778. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  2779. /// <param name="action">Action to convert to an asynchronous action.</param>
  2780. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  2781. /// <returns>Asynchronous action.</returns>
  2782. /// <exception cref="ArgumentNullException"><paramref name="action"/> or <paramref name="scheduler"/> is null.</exception>
  2783. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, IObservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11>(this Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11> action, IScheduler scheduler)
  2784. {
  2785. if (action == null)
  2786. {
  2787. throw new ArgumentNullException(nameof(action));
  2788. }
  2789. if (scheduler == null)
  2790. {
  2791. throw new ArgumentNullException(nameof(scheduler));
  2792. }
  2793. return s_impl.ToAsync(action, scheduler);
  2794. }
  2795. /// <summary>
  2796. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the default scheduler.
  2797. /// </summary>
  2798. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  2799. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  2800. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  2801. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  2802. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  2803. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  2804. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  2805. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  2806. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  2807. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  2808. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  2809. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  2810. /// <param name="action">Action to convert to an asynchronous action.</param>
  2811. /// <returns>Asynchronous action.</returns>
  2812. /// <exception cref="ArgumentNullException"><paramref name="action"/> is null.</exception>
  2813. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, IObservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12>(this Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12> action)
  2814. {
  2815. if (action == null)
  2816. {
  2817. throw new ArgumentNullException(nameof(action));
  2818. }
  2819. return s_impl.ToAsync(action);
  2820. }
  2821. /// <summary>
  2822. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the specified scheduler.
  2823. /// </summary>
  2824. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  2825. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  2826. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  2827. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  2828. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  2829. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  2830. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  2831. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  2832. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  2833. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  2834. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  2835. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  2836. /// <param name="action">Action to convert to an asynchronous action.</param>
  2837. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  2838. /// <returns>Asynchronous action.</returns>
  2839. /// <exception cref="ArgumentNullException"><paramref name="action"/> or <paramref name="scheduler"/> is null.</exception>
  2840. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, IObservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12>(this Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12> action, IScheduler scheduler)
  2841. {
  2842. if (action == null)
  2843. {
  2844. throw new ArgumentNullException(nameof(action));
  2845. }
  2846. if (scheduler == null)
  2847. {
  2848. throw new ArgumentNullException(nameof(scheduler));
  2849. }
  2850. return s_impl.ToAsync(action, scheduler);
  2851. }
  2852. /// <summary>
  2853. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the default scheduler.
  2854. /// </summary>
  2855. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  2856. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  2857. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  2858. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  2859. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  2860. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  2861. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  2862. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  2863. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  2864. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  2865. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  2866. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  2867. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  2868. /// <param name="action">Action to convert to an asynchronous action.</param>
  2869. /// <returns>Asynchronous action.</returns>
  2870. /// <exception cref="ArgumentNullException"><paramref name="action"/> is null.</exception>
  2871. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, IObservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13>(this Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13> action)
  2872. {
  2873. if (action == null)
  2874. {
  2875. throw new ArgumentNullException(nameof(action));
  2876. }
  2877. return s_impl.ToAsync(action);
  2878. }
  2879. /// <summary>
  2880. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the specified scheduler.
  2881. /// </summary>
  2882. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  2883. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  2884. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  2885. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  2886. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  2887. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  2888. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  2889. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  2890. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  2891. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  2892. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  2893. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  2894. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  2895. /// <param name="action">Action to convert to an asynchronous action.</param>
  2896. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  2897. /// <returns>Asynchronous action.</returns>
  2898. /// <exception cref="ArgumentNullException"><paramref name="action"/> or <paramref name="scheduler"/> is null.</exception>
  2899. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, IObservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13>(this Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13> action, IScheduler scheduler)
  2900. {
  2901. if (action == null)
  2902. {
  2903. throw new ArgumentNullException(nameof(action));
  2904. }
  2905. if (scheduler == null)
  2906. {
  2907. throw new ArgumentNullException(nameof(scheduler));
  2908. }
  2909. return s_impl.ToAsync(action, scheduler);
  2910. }
  2911. /// <summary>
  2912. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the default scheduler.
  2913. /// </summary>
  2914. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  2915. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  2916. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  2917. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  2918. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  2919. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  2920. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  2921. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  2922. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  2923. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  2924. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  2925. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  2926. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  2927. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  2928. /// <param name="action">Action to convert to an asynchronous action.</param>
  2929. /// <returns>Asynchronous action.</returns>
  2930. /// <exception cref="ArgumentNullException"><paramref name="action"/> is null.</exception>
  2931. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, IObservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14>(this Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14> action)
  2932. {
  2933. if (action == null)
  2934. {
  2935. throw new ArgumentNullException(nameof(action));
  2936. }
  2937. return s_impl.ToAsync(action);
  2938. }
  2939. /// <summary>
  2940. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the specified scheduler.
  2941. /// </summary>
  2942. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  2943. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  2944. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  2945. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  2946. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  2947. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  2948. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  2949. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  2950. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  2951. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  2952. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  2953. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  2954. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  2955. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  2956. /// <param name="action">Action to convert to an asynchronous action.</param>
  2957. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  2958. /// <returns>Asynchronous action.</returns>
  2959. /// <exception cref="ArgumentNullException"><paramref name="action"/> or <paramref name="scheduler"/> is null.</exception>
  2960. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, IObservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14>(this Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14> action, IScheduler scheduler)
  2961. {
  2962. if (action == null)
  2963. {
  2964. throw new ArgumentNullException(nameof(action));
  2965. }
  2966. if (scheduler == null)
  2967. {
  2968. throw new ArgumentNullException(nameof(scheduler));
  2969. }
  2970. return s_impl.ToAsync(action, scheduler);
  2971. }
  2972. /// <summary>
  2973. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the default scheduler.
  2974. /// </summary>
  2975. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  2976. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  2977. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  2978. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  2979. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  2980. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  2981. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  2982. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  2983. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  2984. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  2985. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  2986. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  2987. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  2988. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  2989. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the action.</typeparam>
  2990. /// <param name="action">Action to convert to an asynchronous action.</param>
  2991. /// <returns>Asynchronous action.</returns>
  2992. /// <exception cref="ArgumentNullException"><paramref name="action"/> is null.</exception>
  2993. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, IObservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15>(this Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15> action)
  2994. {
  2995. if (action == null)
  2996. {
  2997. throw new ArgumentNullException(nameof(action));
  2998. }
  2999. return s_impl.ToAsync(action);
  3000. }
  3001. /// <summary>
  3002. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the specified scheduler.
  3003. /// </summary>
  3004. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  3005. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  3006. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  3007. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  3008. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  3009. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  3010. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  3011. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  3012. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  3013. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  3014. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  3015. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  3016. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  3017. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  3018. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the action.</typeparam>
  3019. /// <param name="action">Action to convert to an asynchronous action.</param>
  3020. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  3021. /// <returns>Asynchronous action.</returns>
  3022. /// <exception cref="ArgumentNullException"><paramref name="action"/> or <paramref name="scheduler"/> is null.</exception>
  3023. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, IObservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15>(this Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15> action, IScheduler scheduler)
  3024. {
  3025. if (action == null)
  3026. {
  3027. throw new ArgumentNullException(nameof(action));
  3028. }
  3029. if (scheduler == null)
  3030. {
  3031. throw new ArgumentNullException(nameof(scheduler));
  3032. }
  3033. return s_impl.ToAsync(action, scheduler);
  3034. }
  3035. /// <summary>
  3036. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the default scheduler.
  3037. /// </summary>
  3038. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  3039. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  3040. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  3041. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  3042. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  3043. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  3044. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  3045. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  3046. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  3047. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  3048. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  3049. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  3050. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  3051. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  3052. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the action.</typeparam>
  3053. /// <typeparam name="TArg16">The type of the sixteenth argument passed to the action.</typeparam>
  3054. /// <param name="action">Action to convert to an asynchronous action.</param>
  3055. /// <returns>Asynchronous action.</returns>
  3056. /// <exception cref="ArgumentNullException"><paramref name="action"/> is null.</exception>
  3057. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TArg16, IObservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TArg16>(this Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TArg16> action)
  3058. {
  3059. if (action == null)
  3060. {
  3061. throw new ArgumentNullException(nameof(action));
  3062. }
  3063. return s_impl.ToAsync(action);
  3064. }
  3065. /// <summary>
  3066. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the specified scheduler.
  3067. /// </summary>
  3068. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  3069. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  3070. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  3071. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  3072. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  3073. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  3074. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  3075. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  3076. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  3077. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  3078. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  3079. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  3080. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  3081. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  3082. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the action.</typeparam>
  3083. /// <typeparam name="TArg16">The type of the sixteenth argument passed to the action.</typeparam>
  3084. /// <param name="action">Action to convert to an asynchronous action.</param>
  3085. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  3086. /// <returns>Asynchronous action.</returns>
  3087. /// <exception cref="ArgumentNullException"><paramref name="action"/> or <paramref name="scheduler"/> is null.</exception>
  3088. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TArg16, IObservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TArg16>(this Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TArg16> action, IScheduler scheduler)
  3089. {
  3090. if (action == null)
  3091. {
  3092. throw new ArgumentNullException(nameof(action));
  3093. }
  3094. if (scheduler == null)
  3095. {
  3096. throw new ArgumentNullException(nameof(scheduler));
  3097. }
  3098. return s_impl.ToAsync(action, scheduler);
  3099. }
  3100. #endregion
  3101. #endregion
  3102. }
  3103. }