Using BackgroundWorker Class let Unity crash.

I try to implement a BackgroundWorker for my Database, so that my applikation does not freeze whenever i try to get huge amount of data out of it.

http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx

All things which happening in my BackgroundWorker is only the Database select execution. I save my results in a List.

At the BackgroundWorker.completed Event i start creating gameobjects based on the database entrys, and than Unity crashes. Always with the error messages:

"!Thread:EqualsCurrentThreadID(m_MainThreadID)"
"!Thread:EqualsCurrentThreadID(GetPersistentManager().GetMainThreadID())&& mode != kCreateObjectDontRegisterInstanceID"
"m_ThreadCheck&&!Thread:EqualsCurrentThreadID(m_ThreadID)"

Is it possible to multithread in Unity3d? And if. Do you have a hint where my mistake could be?

You can't access most of the unity API from threads, it'll just blow up like you've seen

What you need to do is buffer the creation requests into an array or list, then read them from Update

This goes for moving objects (via physics or transform), creating components and gameobjects, textures, and many other things - basically everything extending from UnityEngine.Object (And some which don't on top of that)

Cool, you could lock here for multi-threading ThreadQueue | Integration | Unity Asset Store

it’s a part of SQLiteKit | Integration | Unity Asset Store which actualy already has asynchronous sqlite database processing.

good example:
http://forum.unity3d.com/threads/152557-Meet-new-easy-thread-queue-asset!