But as soon as I want to spawn an actor, Visual Studio reports “A breakpoint instruction (__debugbreak() statement or a similar call) was executed in UnrealEditor.exe.”
I think I’m in the wrong thread if I want to spawn the Actor. A picture of the CallStack.
If you are using threads (via FRunnnable) then you need to call spawn within the game thread ONLY.
You can use thread safe containers like Queues (TQueue) to pass data.
Then in tick you can check the data => read the data from the queue => dequeue it.
The queue is thread-safe in both modes. The [Dequeue()](https://docs.unrealengine.com/5.3/en-US/API/Runtime/Core/Containers/TQueue/Dequeue) method ensures thread-safety by writing it in a way that does not depend on possible instruction reordering on the CPU. The [Enqueue()](https://docs.unrealengine.com/5.3/en-US/API/Runtime/Core/Containers/TQueue/Enqueue/1) method uses an atomic compare-and-swap in multiple-producers scenarios.
I use a FNonAbandonableTask, sorry, i forget to say this important thing. In the SQLiteAlbumDTO i have a pointer to the SQLite instance and i am using this to send to broadcast.
class SQLiteAlbumDTO : public FNonAbandonableTask
{
// Code reduced to the minimum
FORCEINLINE TStatId GetStatId()
{
RETURN_QUICK_DECLARE_CYCLE_STAT(SQLiteAlbumDTO, STATGROUP_ThreadPoolAsyncTasks);
}
void DoWork();
};
//static blueprint library ↓
(new FAutoDeleteAsyncTask<SQLiteAlbumDTO>(me, id))->StartBackgroundTask();