Is there a name for this pattern? I've written this kind of thing a few times in JavaScript and recently found myself writing it in C#. Thing is, I expect this has already been implemented in a library somewhere I didn't know what to look for.
In pseudo code it's something like this:
var referenceToPreviousRequest = null;
if (null != referenceToPreviousRequest) {
referenceToPreviousRequest.cancel();
}
referenceToPreviousRequest = setTimeout(function() {
//The thing I ultimately want to do
}, 1000 /*The delay after the last request*/);
Typically I use this kind of code in client side JavaScript, for delaying an AJAX request until a certain amount of time after the last user input, e.g. searching.