Upgrade to ExtJS 4.0.0 - Released 04/26/2011
[extjs.git] / docs / api / Ext.util.TaskRunner.html
1 <!DOCTYPE html><html><head><title>Ext.util.TaskRunner | Ext JS 4.0 Documentation</title><script type="text/javascript" src="../ext-all.js"></script><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../scrollbars.css" type="text/css"><link rel="stylesheet" href="../docs.css" type="text/css"><link id="styleCss" rel="stylesheet" href="../style.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script><link rel="stylesheet" href="../prettify.css" type="text/css"><!-- link(rel: 'stylesheet', href: req.baseURL + '/css/ext4.css', type: 'text/css')--><link rel="shortcut icon" type="image/ico" href="../favicon.ico"><!--[if IE]>
2 <style type="text/css">.head-band { display: none; }
3 .header { border: 0; top: 0; left: 0px; background: url(../header.gif) repeat-x; }
4 .doc-tab .members .member a.more { background-color: #efefef; }
5 </style><link rel="stylesheet" href="/new/css/ie.css" type="text/css"><![endif]-->
6 </head><body id="ext-body" class="iScroll"><div id="notice" class="notice">For up to date documentation and features, visit 
7 <a href="http://docs.sencha.com/ext-js/4-0">http://docs.sencha.com/ext-js/4-0</a></div><div class="wrapper"><div class="head-band"></div><div class="header"><h2><a href="../index.html">Sencha Documentation</a></h2></div><div id="search"><form><input type="text" placeholder="Search" id="search-field" autocomplete="off" name="q"></form><div id="search-box"></div></div><div id="treePanel"></div><div id="container"><script type="text/javascript">
8
9     req = {
10         liveURL: '.',
11         standAloneMode: true,
12         origDocClass: 'Ext.util.TaskRunner',
13         docClass: 'Ext.util.TaskRunner',
14         docReq: 'Ext.util.TaskRunner',
15         version: '4.0',
16         baseURL: '.',
17         baseDocURL: '.',
18         baseProdURL: '.'
19     };
20
21     clsInfo = {};
22
23
24
25 </script>
26
27 <script type="text/javascript" src="../search.js"></script>
28 <!--script type="text/javascript" src="/new/javascripts/app/examples.js"></script-->
29 <script type="text/javascript" src="../class_tree.js"></script>
30 <script type="text/javascript" src="../class_doc.js"></script>
31 <script type="text/javascript">
32     req.source = 'TaskManager.html#Ext-util.TaskRunner';
33     clsInfo = {"methods":["TaskRunner","start","stop","stopAll"],"cfgs":[],"properties":[],"events":[],"subclasses":["Ext.TaskManager"]};
34     Ext.onReady(function() {
35         Ext.create('Docs.classPanel');
36     });
37 </script><div id="top-block" class="top-block"><h1 id="clsTitle" class="cls"><a href="../source/TaskManager.html#Ext-util.TaskRunner" target="_blank">Ext.util.TaskRunner</a></h1></div><div id="docContent"><div id="doc-overview-content"><div class="lft"><p>Provides the ability to execute one or more arbitrary tasks in a multithreaded
38 manner.  Generally, you can use the singleton <a href="Ext.TaskManager.html" rel="Ext.TaskManager" class="docClass">Ext.TaskManager</a> instead, but
39 if needed, you can create separate instances of TaskRunner.  Any number of
40 separate tasks can be started at any time and will run independently of each
41 other. Example usage:</p>
42
43 <pre class="prettyprint"><code>// Start a simple clock task that updates a div once per second
44 var updateClock = function(){
45     Ext.fly('clock').update(new Date().format('g:i:s A'));
46
47 var task = {
48     run: updateClock,
49     interval: 1000 //1 second
50 }
51 var runner = new Ext.util.TaskRunner();
52 runner.start(task);
53
54 // equivalent using TaskManager
55 Ext.TaskManager.start({
56     run: updateClock,
57     interval: 1000
58 });
59
60 </code></pre>
61
62
63 <p>See the <a href="Ext.util.TaskRunner.html#start" rel="Ext.util.TaskRunner#start" class="docClass">start</a> method for details about how to configure a task object.</p>
64
65
66 <p>Also see <a href="Ext.util.DelayedTask.html" rel="Ext.util.DelayedTask" class="docClass">Ext.util.DelayedTask</a>.</p>
67 <div class="members"><div class="m-methods"><a name="methods"></a><div class="definedBy">Defined By</div><h3 class="mth p">Methods</h3><div id="method-TaskRunner" class="member f ni"><a href="Ext.util.TaskRunner.html#method-TaskRunner" rel="method-TaskRunner" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.util.TaskRunner.html" class="definedIn docClass">Ext.util.TaskRunner</a><br/><a href="../source/TaskManager.html#Ext-util.TaskRunner-method-constructor" class="viewSource">view source</a></div><a name="TaskRunner"></a><a name="method-TaskRunner"></a><a href="Ext.util.TaskRunner.html#" rel="method-TaskRunner" class="cls expand">TaskRunner</a>(
68 <span class="pre">[Number interval]</span>)
69  : void</div><div class="description"><div class="short"><p>&nbsp;</p></div><div class="long">
70 <h3 class="pa">Parameters</h3><ul><li><span class="pre">interval</span> : Number<div class="sub-desc"><p>(optional) The minimum precision in milliseconds supported by this TaskRunner instance
71 (defaults to 10)</p>
72 </div></li></ul><h3 class="pa">Returns</h3><ul><li><span class="pre">void</span>&nbsp; &nbsp;
73 </li></ul></div></div></div><div id="method-start" class="member ni"><a href="Ext.util.TaskRunner.html#method-start" rel="method-start" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.util.TaskRunner.html" class="definedIn docClass">Ext.util.TaskRunner</a><br/><a href="../source/TaskManager.html#Ext-util.TaskRunner-method-start" class="viewSource">view source</a></div><a name="start"></a><a name="method-start"></a><a href="Ext.util.TaskRunner.html#" rel="method-start" class="cls expand">start</a>(
74 <span class="pre">[Object task]</span>)
75  : Object</div><div class="description"><div class="short"><p>Starts a new task.</p>
76 </div><div class="long"><p>Starts a new task.</p>
77 <h3 class="pa">Parameters</h3><ul><li><span class="pre">task</span> : Object<div class="sub-desc"><p>A config object that supports the following properties:<ul>
78 <li><code>run</code> : Function<div class="sub-desc"><p>The function to execute each time the task is invoked. The
79 function will be called at each interval and passed the <code>args</code> argument if specified, and the
80 current invocation count if not.</p>
81 <p>If a particular scope (<code>this</code> reference) is required, be sure to specify it using the <code>scope</code> argument.</p>
82 <p>Return <code>false</code> from this function to terminate the task.</p></div></li>
83 <li><code>interval</code> : Number<div class="sub-desc">The frequency in milliseconds with which the task
84 should be invoked.</div></li>
85 <li><code>args</code> : Array<div class="sub-desc">(optional) An array of arguments to be passed to the function
86 specified by <code>run</code>. If not specified, the current invocation count is passed.</div></li>
87 <li><code>scope</code> : Object<div class="sub-desc">(optional) The scope (<tt>this</tt> reference) in which to execute the
88 <code>run</code> function. Defaults to the task config object.</div></li>
89 <li><code>duration</code> : Number<div class="sub-desc">(optional) The length of time in milliseconds to invoke
90 the task before stopping automatically (defaults to indefinite).</div></li>
91 <li><code>repeat</code> : Number<div class="sub-desc">(optional) The number of times to invoke the task before
92 stopping automatically (defaults to indefinite).</div></li>
93 </ul></p>
94
95
96 <p>Before each invocation, <a href="Ext.html" rel="Ext" class="docClass">Ext</a> injects the property <code>taskRunCount</code> into the task object so
97 that calculations based on the repeat count can be performed.</p>
98
99 </div></li></ul><h3 class="pa">Returns</h3><ul><li><span class="pre">Object</span>&nbsp; &nbsp;<p>The task</p>
100 </li></ul></div></div></div><div id="method-stop" class="member ni"><a href="Ext.util.TaskRunner.html#method-stop" rel="method-stop" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.util.TaskRunner.html" class="definedIn docClass">Ext.util.TaskRunner</a><br/><a href="../source/TaskManager.html#Ext-util.TaskRunner-method-stop" class="viewSource">view source</a></div><a name="stop"></a><a name="method-stop"></a><a href="Ext.util.TaskRunner.html#" rel="method-stop" class="cls expand">stop</a>(
101 <span class="pre">Object task</span>)
102  : Object</div><div class="description"><div class="short"><p>Stops an existing running task.</p>
103 </div><div class="long"><p>Stops an existing running task.</p>
104 <h3 class="pa">Parameters</h3><ul><li><span class="pre">task</span> : Object<div class="sub-desc"><p>The task to stop</p>
105 </div></li></ul><h3 class="pa">Returns</h3><ul><li><span class="pre">Object</span>&nbsp; &nbsp;<p>The task</p>
106 </li></ul></div></div></div><div id="method-stopAll" class="member ni"><a href="Ext.util.TaskRunner.html#method-stopAll" rel="method-stopAll" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.util.TaskRunner.html" class="definedIn docClass">Ext.util.TaskRunner</a><br/><a href="../source/TaskManager.html#Ext-util.TaskRunner-method-stopAll" class="viewSource">view source</a></div><a name="stopAll"></a><a name="method-stopAll"></a><a href="Ext.util.TaskRunner.html#" rel="method-stopAll" class="cls expand">stopAll</a> : void</div><div class="description"><div class="short"><p>Stops all tasks that are currently running.</p>
107 </div><div class="long"><p>Stops all tasks that are currently running.</p>
108 <h3 class="pa">Returns</h3><ul><li><span class="pre">void</span>&nbsp; &nbsp;
109 </li></ul></div></div></div></div></div></div></div><div id="pageContent"></div></div></div></div></body></html>