Thread::GetCurrentThreadID () != m_DeallocThread apears

Hi in my project i am working with terran and trees to create better trees placement for our game.
It is editor extension
EditorWindow ([MenuItem(“Window/TreeEditor”)])

And this error probably apperas when i am my own trees (model, converting to trees in terrain, or trees from terrain to gameobjects

This methos is called from void OnGUI() method

Errors:

!Thread::EqualsCurrentThreadIDForAssert (m_AllocThread)
UnityEditor.DockArea:OnGUI()

Thread::GetCurrentThreadID () != m_DeallocThread
UnityEditor.DockArea:OnGUI()

I am quite sure than nowhere in my code i am creating other threads, no background worker, no threads, coroutins nothnig

Where could be problem?

GameObject-> terrain

     TreeInstance [] instances = new TreeInstance [trees.Count];
               for(int i=0; i<trees.Count; i++) {
                ITree tree = trees *;*

TreeInstance tI = new TreeInstance();
tI.position = new Vector3(tree.transform.position.x / map.terrain.terrainData.size.x, tree.transform.position.y / map.terrain.terrainData.size.y, tree.transform.position.z / map.terrain.terrainData.size.z);
tI.prototypeIndex = 0;
float scale =0.2f + Mathf.Min(0.8f, (float)tree.GetAge() / (float)Tree1.MAXAGE);
tI.heightScale = scale;
tI.widthScale = scale;
instances = tI;
}
map.terrain.terrainData.treeInstances = instances;
f.DeleteDead(trees);
Terrain → Game object
List trees = new List();
TreeInstance [] instances = map.terrain.terrainData.treeInstances;
if (instances.Length == 0)
{
Debug.Log(“no trees in terrain”);
return;
}
for (int i = instances.GetLength(0) - 1; i >= 0; i–)
{

if (instances .prototypeIndex == 0)
{

ITree temp = ((GameObject)PrefabUtility.InstantiatePrefab(treePreafb.gameObject)).GetComponent();
temp.transform.position = new Vector3(instances .position.x * (float)map.GetHeight(), 10, instances .position.z * (float)map.GetWidth());
// ITree temp = ((GameObject)ITree.Instantiate(treePreafb.gameObject, new Vector3(instances .position.x * (float)map.GetHeight(), 10, instances .position.z * (float)map.GetWidth()), Quaternion.identity)).GetComponent();
temp.AddHealth(100);
if (instances .heightScale == 1)
{
temp.SetAge((short)Random.Range(1, 100));
// Random.Range
}
else
{
temp.SetAge((short)((instances .heightScale - 0.2f) * (float)Tree1.MAXAGE));
}
temp.SetYearChange(0);
if (temp == null)
{
Debug.Log(“error”);
}
trees.Add(temp);
}
}
f = new Forest(trees, trees, map);
Terrain.activeTerrain.terrainData.treeInstances = new TreeInstance [0];

I also encountered this problem. The solution is before calling

map.terrain.terrainData.treeInstances = instances;

call

map.terrain.terrainData.RefreshPrototypes();

Took my an eternity to find this solution, since I could not find a connection between OnGUI() and trees.