# Task in @MainActor Function Appears to Become Detached

**URL:** <https://forums.swift.org/t/task-in-mainactor-function-appears-to-become-detached/70584>\
**Category:** Using Swift\
**Tags:** concurrency, actors, mainactor\
**Created:** [March 11, 2024, 8:02pm UTC](https://forums.swift.org/t/task-in-mainactor-function-appears-to-become-detached/70584 "2024-03-11T20:02:19Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![ktoso](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/ktoso/32/44526_2.png) [@ktoso](https://forums.swift.org/u/ktoso)\
**Post date:** [March 12, 2024, 3:45am UTC](https://forums.swift.org/t/task-in-mainactor-function-appears-to-become-detached/70584/5 "2024-03-12T03:45:07Z")

</div>

> [@hgraves](#):
>
> I’m not even sure if spawning a `Task` comes with any guarantees that the next line executes before the `Task` is scheduled to do anything at any time

You're right that there's no such guarantee today.

However, we are working on providing more guarantees there; see this ongoing pitch: [`@isolated(any)` function types](https://forums.swift.org/t/isolated-any-function-types/70562/)

---

_[View the full topic](https://forums.swift.org/t/task-in-mainactor-function-appears-to-become-detached/70584)._
