Thread safe?

I would like to know if it is thread safe to create a Task on the Scheduler from a thread that is not the main thread to run a function of the API?

I believe if you schedule a synchronous task from an async thread it will run the scheduled task in the main thread. So yes, it would be thread-safe.

I think that too, but I would like to know if it is safe to run a scheduled task from an async thread.

I chose not too because it’s hard to tell what other plugins are doing when executing the commands in the scheduler. I thought about it but I have a feeling it would cause problems down the road

If the scheduler is thread safe, there is no problem to do that, but I don’t if it is.

The scheduler is thread safe.

That’s literally what it’s meant for.

1 Like

I know it is thread safe for the API but is it thread safe to create a task from an async thread?

Use the Scheduler from every thread u want! It’ll work fine :slight_smile:

1 Like

basically if you add a task to the scheduler from thread “foo”, it will sit in the scheduler until the main thread is able to run the task.

Basically, as long as your task does not access anything belonging to thread “foo” it will be as if it was from the main thread the entire time.

4 Likes