# C#: Await Completion

Source: https://tweens.gd/csharp/playback/

Every start returns a handle. Await it to continue once the tween ends, or use it to pause and cancel the tween on the way.

Interactive preview: https://tweens.gd/csharp/playback/

## Scripting it

The remote’s buttons call this script’s methods. To build your own, attach it to a scene’s root `Node2D`, pick a `Sprite2D` for **Sprite** in the Inspector, and connect each button’s `pressed` signal to its method.

PlaybackRemote.cs

```csharp
using Godot;
using tweens.gd;

// The remote's buttons call these methods; Ended reports how the movement ended.
public partial class PlaybackRemote : Node2D
{
    [Signal]
    public delegate void EndedEventHandler(Reason reason);

    [Export] private Sprite2D sprite = null!;
    [Export] private Vector2 to = new(1024, 128);

    private TweenInstance? movement;

    public async void Start()
    {
        movement = sprite.TweenPosition(to, 2.4, InOut.SmootherStep);
        EmitSignalEnded(await movement.End);
    }

    public void Pause() => movement?.Pause();

    public void Resume() => movement?.Resume();

    public void Cancel() => movement?.Cancel();
}
```

1.  **Keep the handle.** `TweenPosition` returns it at once, and `Start` keeps it in `movement`.
2.  **Await the end.** `await movement.End` resumes once playback ends, with the reason: `Completed`, `Cancelled`, or `OwnerExited` when the scene closes first.
3.  **Control it.** `Pause` holds the current value until `Resume`. `Cancel` stops for good and keeps the latest value.

To stop every tween a node owns without keeping their handles, call `sprite.CancelTweens()`.

## React to the end

Await the handle to continue in the same method. `End` resumes however playback ended, so check the reason when the next step needs an arrival.

Await

```csharp
var movement = sprite.TweenPosition((400, 180), 0.6, Out.Cubic);

if (await movement.End == Reason.Completed)
    GD.Print("Arrived");
```

A callback on the definition suits a small synchronous reaction. `OnEnd` runs only on natural completion.

Callback

```csharp
var arrive = new Tweens.Position2D((400, 180), 0.6, Out.Cubic)
{
    OnEnd = _ => GD.Print("Arrived"),
};

sprite.Tween(arrive);
```

`OnFinally` also runs when playback stops early or fails; [callback order](https://tweens.gd/csharp/api/callbacks/#callback-order) shows the whole lifecycle.

Await on Godot’s main thread

An exception in an ease, setter, or callback faults playback, and awaiting `End` throws it. Catch it in `async void` methods such as `_Ready`. Create, control, and await tweens on the main thread, and never block on `End` with `.Wait()` or `.Result`.

### Would you like to know more?

[Cancellation](https://tweens.gd/csharp/cancellation/)Stop tweens early and guard a sequence.

[Sequences](https://tweens.gd/csharp/sequences/)Link motions or play them together.

[Easings](https://tweens.gd/easings/)Compare easing curves.

[Catalog](https://tweens.gd/csharp/nodes/)Choose what to animate next.
