当前位置: 首页>>代码示例>>C#>>正文


C# Promise.ThenAll方法代码示例

本文整理汇总了C#中Promise.ThenAll方法的典型用法代码示例。如果您正苦于以下问题:C# Promise.ThenAll方法的具体用法?C# Promise.ThenAll怎么用?C# Promise.ThenAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Promise的用法示例。


在下文中一共展示了Promise.ThenAll方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ChainMultiplePromisesUsingAllAndConvertToNonValuePromise

        public void ChainMultiplePromisesUsingAllAndConvertToNonValuePromise()
        {
            var promise = new Promise<string>();
            var chainedPromise1 = new Promise();
            var chainedPromise2 = new Promise();

            var completed = 0;

            promise
                //.ThenAll(i => LinqExts.FromItems(chainedPromise1, chainedPromise2).Cast<IPromise>())
                .ThenAll(i => new[]{chainedPromise1, chainedPromise2})
                .Then(() =>
                {
                    ++completed;
                });

            Assert.AreEqual(0, completed);

            promise.Resolve("hello");

            Assert.AreEqual(0, completed);

            chainedPromise1.Resolve();

            Assert.AreEqual(0, completed);

            chainedPromise2.Resolve();

            Assert.AreEqual(1, completed);
        }
开发者ID:rob-blackbourn,项目名称:JetBlack.Promises,代码行数:30,代码来源:PromiseFixture.cs

示例2: ChainMultiplePromisesUsingAllThatAreResolvedOutOfOrder

        public void ChainMultiplePromisesUsingAllThatAreResolvedOutOfOrder()
        {
            var promise = new Promise<string>();
            var chainedPromise1 = new Promise<int>();
            var chainedPromise2 = new Promise<int>();
            const int chainedResult1 = 10;
            const int chainedResult2 = 15;

            var completed = 0;

            promise
                //.ThenAll(i => LinqExts.FromItems(chainedPromise1, chainedPromise2).Cast<IPromise<int>>())
                .ThenAll(i => new[]{chainedPromise1, chainedPromise2})
                .Then(result =>
                {
                    var items = result.ToArray();
                    Assert.AreEqual(2, items.Length);
                    Assert.AreEqual(chainedResult1, items[0]);
                    Assert.AreEqual(chainedResult2, items[1]);

                    ++completed;
                });

            Assert.AreEqual(0, completed);

            promise.Resolve("hello");

            Assert.AreEqual(0, completed);

            chainedPromise2.Resolve(chainedResult2);

            Assert.AreEqual(0, completed);

            chainedPromise1.Resolve(chainedResult1);

            Assert.AreEqual(1, completed);
        }
开发者ID:rob-blackbourn,项目名称:JetBlack.Promises,代码行数:37,代码来源:PromiseFixture.cs

示例3: chain_multiple_value_promises_using_all_resolved_out_of_order

        public void chain_multiple_value_promises_using_all_resolved_out_of_order()
        {
            var promise = new Promise();
            var chainedPromise1 = new Promise<int>();
            var chainedPromise2 = new Promise<int>();
            var chainedResult1 = 10;
            var chainedResult2 = 15;

            var completed = 0;

            promise
                .ThenAll(() => LinqExts.FromItems(chainedPromise1, chainedPromise2).Cast<IPromise<int>>())
                .Then(result =>
                {
                    var items = result.ToArray();
                    Assert.Equal(2, items.Length);
                    Assert.Equal(chainedResult1, items[0]);
                    Assert.Equal(chainedResult2, items[1]);

                    ++completed;
                });

            Assert.Equal(0, completed);

            promise.Resolve();

            Assert.Equal(0, completed);

            chainedPromise2.Resolve(chainedResult2);

            Assert.Equal(0, completed);

            chainedPromise1.Resolve(chainedResult1);

            Assert.Equal(1, completed);
        }
开发者ID:Renanse,项目名称:C-Sharp-Promise,代码行数:36,代码来源:Promise_NonGeneric_Tests.cs

示例4: chain_multiple_promises_using_all

        public void chain_multiple_promises_using_all()
        {
            var promise = new Promise();
            var chainedPromise1 = new Promise();
            var chainedPromise2 = new Promise();

            var completed = 0;

            promise
                .ThenAll(() => LinqExts.FromItems(chainedPromise1, chainedPromise2).Cast<IPromise>())
                .Then(() => ++completed);

            Assert.Equal(0, completed);

            promise.Resolve();

            Assert.Equal(0, completed);

            chainedPromise1.Resolve();

            Assert.Equal(0, completed);

            chainedPromise2.Resolve();

            Assert.Equal(1, completed);
        }
开发者ID:Renanse,项目名称:C-Sharp-Promise,代码行数:26,代码来源:Promise_NonGeneric_Tests.cs

示例5: ChainMultiplePromisesUsingAll

        public void ChainMultiplePromisesUsingAll()
        {
            var promise = new Promise();
            var chainedPromise1 = new Promise();
            var chainedPromise2 = new Promise();

            var completed = 0;

            promise
                //.ThenAll(() => LinqExts.FromItems(chainedPromise1, chainedPromise2).Cast<IPromise>())
                .ThenAll(() => new []{chainedPromise1, chainedPromise2})
                .Then(() => ++completed);

            Assert.AreEqual(0, completed);

            promise.Resolve();

            Assert.AreEqual(0, completed);

            chainedPromise1.Resolve();

            Assert.AreEqual(0, completed);

            chainedPromise2.Resolve();

            Assert.AreEqual(1, completed);
        }
开发者ID:rob-blackbourn,项目名称:JetBlack.Promises,代码行数:27,代码来源:PromiseNonGenericFixture.cs

示例6: chain_multiple_promises_using_all_and_convert_to_non_value_promise

        public void chain_multiple_promises_using_all_and_convert_to_non_value_promise()
        {
            var promise = new Promise<string>();
            var chainedPromise1 = new Promise();
            var chainedPromise2 = new Promise();

            var completed = 0;

            promise
                .ThenAll(i => LinqExts.FromItems(chainedPromise1, chainedPromise2).Cast<IPromise>())
                .Then(() =>
                {
                    ++completed;
                });

            Assert.Equal(0, completed);

            promise.Resolve("hello");

            Assert.Equal(0, completed);

            chainedPromise1.Resolve();

            Assert.Equal(0, completed);

            chainedPromise2.Resolve();

            Assert.Equal(1, completed);
        }
开发者ID:Renanse,项目名称:C-Sharp-Promise,代码行数:29,代码来源:PromiseTests.cs


注:本文中的Promise.ThenAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。