Class

# WebThread

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

A `Session</api/web/session>`-aware thread for use in web apps.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                                         | Type                                       | Read-Only | Shared |
|----------------------------------------------|--------------------------------------------|-----------|--------|
| `Current<webthread.current>`                 | `Thread</api/language/threading/thread>`   | ✓         | ✓      |
| `DebugIdentifier<webthread.debugidentifier>` | `String</api/data_types/string>`           |           |        |
| `Priority<webthread.priority>`               | `Integer</api/data_types/integer>`         |           |        |
| `StackSize<webthread.stacksize>`             | `Integer</api/data_types/integer>`         |           |        |
| `ThreadID<webthread.threadid>`               | `Integer</api/data_types/integer>`         | ✓         |        |
| `ThreadState<webthread.threadstate>`         | `Thread.ThreadStates<thread.threadstates>` | ✓         |        |
| `Type<webthread.type>`                       | `Types<thread.types>`                      |           |        |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                                       | Parameters                                                                                                                                                                                                                         | Returns | Shared |
|------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|--------|
| `AddUserInterfaceUpdate<webthread.adduserinterfaceupdate>` | data As `Dictionary</api/language/dictionary>`                                                                                                                                                                                     |         |        |
|                                                            | `ParamArray</api/language/paramarray>` data As `Pair</api/language/pair>`                                                                                                                                                          |         |        |
| `Pause<webthread.pause>`                                   |                                                                                                                                                                                                                                    |         |        |
| `Resume<webthread.resume>`                                 |                                                                                                                                                                                                                                    |         |        |
| `Sleep<webthread.sleep>`                                   | milliseconds As `Integer</api/data_types/integer>`, wakeEarly As `Boolean</api/data_types/boolean>` = `False</api/language/false>`                                                                                                 |         |        |
| `SleepCurrent<webthread.sleepcurrent>`                     | milliseconds As `Integer</api/data_types/integer>`                                                                                                                                                                                 |         | ✓      |
| `Start<webthread.start>`                                   |                                                                                                                                                                                                                                    |         |        |
| `StartMethod<webthread.startmethod>`                       | start As StartMethod, type As `Thread.Types<thread.types>` = `Thread.Types<thread.types>`.Cooperative, completion As Thread.StartMethodCompleted = `Nil</api/language/nil>`                                                        |         |        |
|                                                            | method As StartMethodWithValue, value as `Variant</api/data_types/variant>`, type As `Thread.Types<thread.types>` = `Thread.Types<thread.types>`.Cooperative, completion As Thread.StartMethodCompleted = `Nil</api/language/nil>` |         |        |
| `Stop<webthread.stop>`                                     |                                                                                                                                                                                                                                    |         |        |
| `YieldToNext<webthread.yieldtonext>`                       |                                                                                                                                                                                                                                    |         | ✓      |

## Events

<div class="rst-class">

table-centered_column_4

</div>

| Name                                                 | Parameters                                       | Returns |
|------------------------------------------------------|--------------------------------------------------|---------|
| `Run<webthread.run>`                                 |                                                  |         |
| `UserInterfaceUpdate<webthread.userinterfaceupdate>` | data() As `Dictionary</api/language/dictionary>` |         |

## Property descriptions

<div id="webthread.current">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebThread.Current

**Current** As `Thread</api/language/threading/thread>`

> Returns the thread that was executing at the moment this property was read.
>
> This property is read-only.
>
> This property is `shared</api/language/shared>`.
>
> This property is `Nil</api/language/nil>` when accessed from the main thread.

<div id="webthread.debugidentifier">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebThread.DebugIdentifier

**DebugIdentifier** As `String</api/data_types/string>`

> Identifier which will show up in the debugger's thread popup.

<div id="webthread.priority">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebThread.Priority

**Priority** As `Integer</api/data_types/integer>`

> Gets and sets the relative priority of the thread.
>
> The Priority can be changed while a Thread is running.
>
> The application's main thread has a priority of 5 and this is also the default value of any programmatically created threads. If you don't modify this value, your application will behave normally, in the sense that all the threads will share the CPU's resources equally.
>
> Increasing the value of *Priority* above 5 gives that thread more processing cycles than other threads. Doubling the value of *Priority* will double the number of processing cycles the thread gets. A thread with a *Priority* of 1 will get one-fifth the processing cycles as the main thread. The range is 1 to 2^31-1, but very high values of *Priority* will make it difficult for other threads to run at all. The value of *Priority* changes the way in which threads get processing cycles only if their values are not all equal. You can use the following class constants to assign to *Priority* or to compare its value:
>
> | Value | Description    |
> |-------|----------------|
> | 1     | LowestPriority |
> | 5     | NormalPriority |
> | 10    | HighPriority   |
>
> You do not need to use these constants; you can use any legal integer value instead.
>
> This example lowers the priority of the thread prior to calling its Run method.
>
> ``` xojo
> Thread1.Priority = Thread.LowestPriority
> Thread1.Run
> ```

<div id="webthread.stacksize">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebThread.StackSize

**StackSize** As `Integer</api/data_types/integer>`

> The size of the stack, in bytes.
>
> The StackSize can only be set when the thread is not running. The default stack size is 512KB on macOS and Linux and 1MB on Windows. A StackSize of zero indicates the default is used.
>
> There is generally little reason to change this. Each stack frame only need to contain information about the parameters, local variables and return address for a method call. This does not include memory needed for objects. It would take a significant amount of local variables or parameters with method calls that are 100s of levels deep in order to exhaust the stack space.
>
> ``` xojo
> Thread1.StackSize = 96000
> ```

<div id="webthread.threadid">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebThread.ThreadID

**ThreadID** As `Integer</api/data_types/integer>`

> ID of the thread, assigned at runtime.
>
> This property is read-only.
>
> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> `ThreadID<thread.threadid>` will be non-zero only when the `Thread</api/language/threading/thread>` is running.
>
> </div>
>
> This example reports the ThreadID only if the thread is running.
>
> ``` xojo
> If LongProcessThread1.State <> Thread.NotRunning Then
>   MessageBox(LongProcessThread1.ThreadID.ToString)
> Else
>   MessageBox("The thread is not running!")
> End If
> ```

<div id="webthread.threadstate">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebThread.ThreadState

**ThreadState** As `Thread.ThreadStates<thread.threadstates>`

> Indicates the state of the thread.
>
> This property is read-only.
>
> A thread can be in one of five states. See `Thread<thread.threadstates>` for details.
>
> This window method checks the State of the thread and displays a message in a `TextField</api/user_interface/desktop/desktoptextfield>` on the form. The parameter is:
>
> ``` xojo
> State As Thread.ThreadStates
> ```
>
> ``` xojo
> Select Case State
> Case Thread.ThreadStates.Running
>   TextField1.Text = "Running"
> Case Thread.ThreadStates.Waiting
>   TextField1.Text = "Waiting"
> Case Thread.ThreadStates.Sleeping
>   TextField1.Text = "Sleeping"
> Case Thread.ThreadStates.Paused
>   TextField1.Text = "Paused"
> Case Thread.ThreadStates.NotRunning
>   TextField1.Text = "Not Running"
> End Select
> ```

<div id="webthread.type">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebThread.Type

**Type** As `Types<thread.types>`

> Indicates the type of the <span class="title-ref">WebThread</span>, Cooperative or Preemptive. Cooperative is the default.
>
> Carefully read the `Preemptive Threads<thread.preemptive_threads>` notes before using them.

## Method descriptions

<div id="webthread.adduserinterfaceupdate">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebThread.AddUserInterfaceUpdate

**AddUserInterfaceUpdate**(data As `Dictionary</api/language/dictionary>`)

**AddUserInterfaceUpdate**(`ParamArray</api/language/paramarray>` data As `Pair</api/language/pair>`)

> Triggers the `UserInterfaceUpdate<thread.userinterfaceupdate>` event so you can update your user interface from the thread.

<div id="webthread.pause">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebThread.Pause

**Pause**

> Puts the thread in a paused state. Every call to Pause must be matched by a call to Resume.
>
> The thread will not be allocated any processing cycles, regardless of its assigned *Priority*. It is “asleep.” To wake it up, call the Resume method. If the thread is executing when you call Pause, it will immediately cause a context switch.
>
> This example calls Pause, followed by a call to Resume after other code has executed.
>
> ``` xojo
> LongProcessThread1.Pause
> ' do something else here...
> LongProcessThread1.Resume
> ```

<div id="webthread.resume">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebThread.Resume

**Resume**

> Wakes up a thread that was paused because of a call to `Thread<thread.pause>` or is sleeping because of a call to `Thread<thread.sleep>`. Every call to Pause must be matched by a call to Resume.
>
> When you call Resume, the thread reacquires its ability to receive processing cycles according to its value of *Priority*. Calling Resume will not cause a context switch to take place, that is, a switch to the next thread in the queue.
>
> ``` xojo
> LongProcessThread1.Resume
> ```

<div id="webthread.sleep">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebThread.Sleep

**Sleep**(milliseconds As `Integer</api/data_types/integer>`, wakeEarly As `Boolean</api/data_types/boolean>`=`False</api/language/false>`)

> Puts the thread to sleep for the specified amount of time.
>
> By default, *wakeEarly* is `False</api/language/false>`. If it is not set to `True</api/language/true>`, the thread will be put to sleep for the full amount of time specified by *milliSeconds*. If you set WakeEarly to `True</api/language/true>`, the thread can be resumed early. It will wake up early if there are no other threads able to execute.
>
> ``` xojo
> LongProcessThread1.Sleep(300, True)
> ```

<div id="webthread.sleepcurrent">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebThread.SleepCurrent

**SleepCurrent**(milliseconds As `Integer</api/data_types/integer>`)

> Sleeps the currently executing `thread</api/language/threading/thread>` for the specified number of *milliseconds*.
>
> If the currently executing thread is the main thread, it will sleep like any other thread would.
>
> This method is `shared</api/language/shared>`.

<div id="webthread.start">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebThread.Start

**Start**

> Starts the thread's Run event handler.

<div id="webthread.startmethod">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebThread.StartMethod

**StartMethod**(start As StartMethod, type As `Thread.Types<thread.types>` = `Thread.Types<thread.types>`.Cooperative, completion As Thread.StartMethodCompleted = `Nil</api/language/nil>`)

> A convenient way of running a method in a <span class="title-ref">WebThread</span> without the need for a <span class="title-ref">WebThread</span> subclass.
>
> Starts *start* as the *type* of thread specified. If a *completion* method is provided, it will be called with the thread ends.
>
> The *start* and *completion* methods are `delegates</api/data_types/additional_types/delegate>`. This means the parameter must use `AddressOf</api/language/addressof>` or be a function that returns a `delegate</api/data_types/additional_types/delegate>`.

**StartMethod**(start As StartMethodWithValue, value as `Variant</api/data_types/variant>`, type As `Thread.Types<thread.types>` = `Thread.Types<thread.types>`.Cooperative, completion As Thread.StartMethodCompleted = `Nil</api/language/nil>`)

> Starts *start*, passing the *value*, as the *type* of thread specified. If a *completion* method is provided, it will be called with the thread ends.
>
> The *start* and *completion* methods are `delegates</api/data_types/additional_types/delegate>`. This means the parameter must use `AddressOf</api/language/addressof>` or be a function that returns a `delegate</api/data_types/additional_types/delegate>`.
>
> This example passes the LoadPictures method as the method that will run in the thread, passes a picFolder (a `FolderItem</api/files/folderitem>` as the value parameter, indicates it will be a preemptive thread and passes LoadPicturesCompleted as the *completion* method):
>
> ``` xojo
> Thread.StartMethod(AddressOf LoadPictures, picFolder, Thread.Types.Preemptive, AddressOf LoadPicturesCompleted)
> ```
>
> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> The *completion* method, if provided, executes in the main thread.
>
> </div>

<div id="webthread.stop">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebThread.Stop

**Stop**

> Stops the specified thread.
>
> Internally, this method will cause your thread's stack to unwind, destructors for local objects to be called, and so forth. It's a graceful exit which can cause code to execute. It may also cause context switches.
>
> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> A thread should not stop itself. Instead, just return from the Run event handler to allow the thread to end.
>
> </div>
>
> This example, which is in the Pressed event of a button, stops the thread.
>
> ``` xojo
> LongProcessThread1.Stop
> ```

<div id="webthread.yieldtonext">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebThread.YieldToNext

**YieldToNext**

> Causes the current thread to yield its time to the next thread.
>
> This causes the Thread Scheduler to yield the currently executing thread's processing time to the next `Thread</api/language/threading/thread>` in the queue that is awaiting processing cycles. It is possible for the next `Thread</api/language/threading/thread>` to be the currently executing `Thread</api/language/threading/thread>`.
>
> This method is `shared</api/language/shared>`.

## Event descriptions

<div id="webthread.run">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebThread.Run

**Run**

> The Run method has been called. The threaded code is placed in this event handler. Methods called from here also run in the thread.
>
> macOS apps cannot access the user interface from within a thread. Doing so raises a `ThreadAccessingUIException</api/exceptions/threadaccessinguiexception>`. Instead, use the `Thread<thread.adduserinterfaceupdate>` method in conjunction with the `Thread<thread.userinterfaceupdate>` event. See the `Thread<thread.userinterfaceupdate>` event for an example.

<div id="webthread.userinterfaceupdate">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebThread.UserInterfaceUpdate

**UserInterfaceUpdate**(data() As `Dictionary</api/language/dictionary>`)

> Used to update your app's user interface.
>
> Apps cannot access the user interface from within the `Run<thread.run>` event of a thread. Doing so raises a `ThreadAccessingUIException</api/exceptions/threadaccessinguiexception>`. Instead, use the UserInterfaceUpdate event to update your user interface. It can be triggered by calling the `AddUserInterfaceUpdate<thread.adduserinterfaceupdate>` method from within the `Run<thread.run>` event.
>
> Each call to `AddUserInterfaceUpdate<thread.adduserinterfaceupdate>` in the `Run<thread.run>` event, adds the values passed to an array that is then passed to the UserInterfaceUpdate event (the data() parameter above). This allows you to process all of the calls to `AddUserInterfaceUpdate<thread.adduserinterfaceupdate>` or just the most recent one. For example, if your thread was reading a series of files and you wished to add the name of each file read to a `ListBox</api/user_interface/desktop/desktoplistbox>`, you'd want to read each row of the data() array passed to this event. However, if you instead were only displaying a `ProgressBar</api/user_interface/desktop/desktopprogressbar>` and wanted to show how far you'd gotten through reading all the files, it would be more efficient to read the last item of the data() array passed to this event and then update your `ProgressBar</api/user_interface/desktop/desktopprogressbar>` control rather than iterate through all of the items in the data() array.
>
> This code (in the UserInterfaceUpdate event) updates a ProgressBar (called UIProgress) on a Window:
>
> ``` xojo
> For Each update As Dictionary In data
>   If update.HasKey("UIProgress") Then
>       UIProgress.Value = update.Value("UIProgress").IntegerValue
>   End If
> Next
> ```
>
> The Data parameter is an array of Dictionaries containing information supplied by the `AddUserInterfaceUpdate<thread.adduserinterfaceupdate>` method that can be used to update the UI.
>
> The Run method contains the code that runs in the thread and calls `AddUserInterfaceUpdate<thread.adduserinterfaceupdate>` with any necessary information:
>
> ``` xojo
> Var progressValue As Integer
>
> While progressValue < 100
>   progressValue = progressValue + 1
>
>   //Your processing code goes here. For the sake of this example
>   //we've added a dummy loop below so you can see the progress bar update.
>
>   ' Do nothing for 1/4 second
>   Var waitUntil As Integer = System.Ticks + 15
>   While System.Ticks < waitUntil
>   Wend
>
>   ' Call AddUserInterfaceUpdate with any parameters you need. This calls the UserInterfaceUpdate event handler
>   ' where you can directly access any UI controls on the Window.
>
>   ' This specifies simple parameters using a Pair
>   ' You can also pass values using a Dictionary
>   Me.AddUserInterfaceUpdate("UIProgress":progressValue)
>
> Wend
> ```

## Notes

Use of a <span class="title-ref">WebThread</span> prevents you from having to use `WebSessionContext</api/web/websessioncontext>`.

Allow the thread to go out of scope in order for the web framework to properly manage it. If you keep the thread alive (by having an infinite loop in its Run event handler), your sessions may not quit which could result in memory leaks.

Remember, threads stay in scope as long as they are active (running, sleeping, etc.)

<div class="note">

<div class="title">

Note

</div>

The main reason to use a <span class="title-ref">WebThread</span> is that its session is retained. That means that if you do anything that would require manipulating the session, the framework can accurately figure out which session it belongs to. If you're doing something that is not session sensitive, you could use a regular `Thread</api/language/threading/thread>`.

</div>

## Compatibility

|                       |     |
|-----------------------|-----|
| **Project Types**     | Web |
| **Operating Systems** | All |

<div class="seealso">

`Thread</api/language/threading/thread>` parent class; `Session</api/web/session>`, `WebSession</api/web/websession>`, `WebSessionContext</api/web/websessioncontext>`

</div>
