本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}