本文整理汇总了C#中Promise.Next方法的典型用法代码示例。如果您正苦于以下问题:C# Promise.Next方法的具体用法?C# Promise.Next怎么用?C# Promise.Next使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Promise
的用法示例。
在下文中一共展示了Promise.Next方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: exception_during_Then_onResolved_triggers_error_hander
public void exception_during_Then_onResolved_triggers_error_hander() {
var promise = new Promise<int>();
var callback = 0;
var errorCallback = 0;
var expectedException = new Exception();
promise
.Next<int>(value => {
throw expectedException;
})
.Done(
value => {
++callback;
},
ex => {
Assert.Equal(expectedException, ex);
++errorCallback;
}
);
promise.Resolve(6);
Assert.Equal(0, callback);
Assert.Equal(1, errorCallback);
}
示例2: exception_thrown_in_chain_rejects_resulting_promise
public void exception_thrown_in_chain_rejects_resulting_promise() {
var promise = new Promise<int>();
var chainedPromise = new Promise<string>();
var ex = new Exception();
var errors = 0;
promise
.Next<string>(v => {
throw ex;
})
.Catch(e => {
Assert.Equal(ex, e);
++errors;
});
promise.Resolve(15);
Assert.Equal(1, errors);
}
示例3: rejection_of_source_promise_rejects_chained_promise
public void rejection_of_source_promise_rejects_chained_promise() {
var promise = new Promise<int>();
var chainedPromise = new Promise<string>();
var ex = new Exception();
var errors = 0;
promise
.Next(v => chainedPromise)
.Catch(e => {
Assert.Equal(ex, e);
++errors;
});
promise.Reject(ex);
Assert.Equal(1, errors);
}
示例4: can_chain_promise_and_convert_type_of_value
public void can_chain_promise_and_convert_type_of_value() {
var promise = new Promise<int>();
var chainedPromise = new Promise<string>();
var promisedValue = 15;
var chainedPromiseValue = "blah";
var completed = 0;
promise
.Next(v => chainedPromise)
.Then(v => {
Assert.Equal(chainedPromiseValue, v);
++completed;
});
promise.Resolve(promisedValue);
chainedPromise.Resolve(chainedPromiseValue);
Assert.Equal(1, completed);
}