Changes

Jump to: navigation, search

Learning Collaborative Development Lab Fall 2008 Results

1,138 bytes added, 14:13, 11 September 2008
no edit summary
---
<br />
 
 
Written by: [[User:Scott|Scott Lunel]] <br />
For this lab I was interested to see whether or not it would be possible to run a delayed command under Ubiquity. I've recently<br />been dealing with threads and sleeping them in C++.<br /><br />
At first I attempted something along the lines of:<br />
 
---<br />
<pre>
while(parseInt(cur) < parseInt(secDuration)){
cur = new Date().getTime();
}
 
displayMessage( "Time's Up!" );
</pre>
---
<br />
However this wasn't exactly what I was looking for because it caused the browser to freeze while the command was running.<br /><br />
I did a little more looking and found this method instead:<br />
---<br />
<pre>
CmdUtils.CreateCommand({
name: "Timer",
author: "Scott Lunel",
takes: {"Time": noun_arb_text},
preview: "A simple timer that executes a message to the user after the entered time period.",
execute: function(directObj) {
 
Utils.setTimeout(function() { displayMessage("Time's Up!"); }, parseInt(directObj.text));
}
})
</pre>
---
<br />
Unlike the previous command, it will not freeze the browser while the timed command is being performed.
1
edit

Navigation menu