Observable.Async.cs 228 KB

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