<div class="meta" robots="noindex">

</div>

Method

# Thread.Run

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

<div class="warning">

<div class="title">

Warning

</div>

This item was deprecated in version 2019r2. Please use `Thread.Start<thread.start>` as a replacement.

</div>

## Description

Executes the thread's <span class="title-ref">Run</span> event handler.

## Sample code

The following example illustrates how to update an interface using a `Timer</api/language/timer>` and a Thread. The computation is done in the Thread but the interface is updated via the `Timer</api/language/timer>` in the main thread.

The user interface has a `PushButton</api/deprecated/pushbutton>`, `ProgressBar</api/deprecated/progressbar>`, `Timer</api/language/timer>` and Thread object on the Window.

The Action event of the `PushButton</api/deprecated/pushbutton>` gives the `ProgressBar</api/deprecated/progressbar>` an ititial value and sets the mode of the `Timer</api/language/timer>` to Multiple. The `Timer</api/language/timer>` periodically checks on the status of the `ProgressBar</api/deprecated/progressbar>`.

This is the code in the PushButton Action event hander:

``` xojo
ProgressBar1.Value = 0
Timer1.Mode = Timer.ModeMultiple ' periodically check ProgressBar and update the interface
Thread1.Run
```

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

The `Run<thread.run>` event handler of the Thread is what calculates the value for the `ProgressBar</api/deprecated/progressbar>`. *ProgressValue* is a property (`Double</api/data_types/double>`) of the window.

``` xojo
progressValue = 0

While progressValue < 100 ' if not the Maximum...
  ' recompute progressValue, a property of the Window
  progressValue = progressValue + 1 

  ' do nothing for 1/4 second or so so folks can see the actual progress
  Dim waitUntil As Integer = Ticks + 15
  While ticks < waitUntil
  Wend

Wend
```

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

The `Timer</api/language/timer>` periodically checks the state of the `ProgressBar</api/deprecated/progressbar>`. If it has not reached its maximum value, it updates it with the computed value.

``` xojo
If ProgressBar1.Value >= ProgressBar1.Maximum then ' tests the ProgressBar value
  ProgressBar1.Value = ProgressBar1.Maximum
  Me.Mode = Timer.ModeOff ' turns off the checking/updating
Else ' if not maximum
  ' updates the interface with the current value that was updated by the thread
  ProgressBar1.Value = progressValue 
End If
```

## Compatibility

All project types on all supported operating systems.
