I attempted the code snippet below:
.cs
string someone = "John";
int timer = 3000;
int check = 1;
string script = "<script> runPromise('" + someone + "'," + timer + "," + check + ").then(someone => { console.log('" + someone + "', someone)});</script>";
ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", script);
.aspx
<script>
let runPromise = (someone, timer, check, success = true) => {
console.log(`${someone} start run`);
console.log(check);
return new Promise((resolve, reject) => {
if (check == 1) {
setTimeout(function () {
resolve(`${someone} run ${timer / 1000} second`);
}, timer);
} else {
reject(`${someone} fail`)
}
});
}
</script>
This specific code is only functional within a button setting.
Is there a way to utilize this in a thread or task scenario where I need to wait for around 10 seconds?
Any assistance on this matter would be greatly valued.