本文整理匯總了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);
}