我有调用一个WebService(callPathsToMultiTiffWS),其具有两种可能的应用:在壳体问题与异步而在WinJS
- 完整=真
- 完整=假
完成= false我想显示一个对话框,通知用户比webService失败和两个按钮:
- 重试动作(重新调用WS)
- 退出
这是到目前为止我的代码:
callPathsToMultiTiffWS(UID_KEY[9], stringCapturePaths, UID_KEY[1], UID_KEY[2], UID_KEY[3], UID_KEY[4], UID_KEY[5], UID_KEY[6]).then(
function (complete) {
if (complete == true) {//if true, it stores the id of the picture to delete
Windows.UI.Popups.MessageDialog("WS executed successfully", "Info").showAsync().then(function (complete) {window.close();});
} else {
var messageDialogPopup = new Windows.UI.Popups.MessageDialog("An error occur while calling WS, retry??", "Info");
messageDialogPopup.commands.append(new Windows.UI.Popups.UICommand('Retry', function() { /*code for recall element*/ }));
messageDialogPopup.commands.append(new Windows.UI.Popups.UICommand('Exit', function() { /*code for exit*/ }));
messageDialogPopup.showAsync();
_divInput.innerHTML = "";
}
},
function (error) { console.log("function error"); });
这工作不错,到目前为止,但我想召回功能工作 所以我想以使嵌入我的代码在这样一个循环内
var ban = true;
while (true) {
callPathsToMultiTiffWS(UID_KEY[9], stringCapturePaths, UID_KEY[1], UID_KEY[2], UID_KEY[3], UID_KEY[4], UID_KEY[5], UID_KEY[6]).then(
function (complete) {
if (complete == true) {//if true, it stores the id of the picture to delete
Windows.UI.Popups.MessageDialog("WS executed successfully", "Info").showAsync().then(function (complete) { window.close(); });
} else {
var messageDialogPopup = new Windows.UI.Popups.MessageDialog("An error occur while calling WS, retry??", "Info");
messageDialogPopup.commands.append(new Windows.UI.Popups.UICommand('Retry', function() { ban == true; }));
messageDialogPopup.commands.append(new Windows.UI.Popups.UICommand('Exit', function() { ban == false; }));
messageDialogPopup.showAsync().then(function (complete) {
console.log("no ps no");
});
}
},
function (error) { console.log("function error"); });
if (ban == false) break;
}
此循环执行webService,但它不会等待用户交互来触发web服务触摸其中一个按钮,这是一个无休止的循环调用我的webService,如何解决这个问题?
先感谢您的支持
什么是正是你正在努力实现与循环? –
我想消费一个WebService,如果失败我想用一个重试按钮显示一个消息对话框,只有当用户接受时才重复所有的过程,但是我的循环重复这个过程而不显示消息对话框并且没有用户交互 – Jesus