Observable.Async.cs 228 KB

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