As far as I know, with the exception of certain scheduler objects, we cannot perform this operation in a non-UI thread. We can convert some values between UI threads and non-UI threads, not objects. (Quoted from here)
You can create elements in a background thread, but you can't do much to them. They belong to a background thread, and trying to attach them to a window created by the main thread will cause an error. Such as the question and the problem.
The solution is to avoid creating a large number of elements at once. If possible, you could try to split the work of creating 3000 elements into smaller blocks (for example, create 10 elements at a time) and use the lower priority Dispatcher.BeginInvoke to run these blocks one by one.
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our [documentation][5] to enable e-mail notifications if you want to receive the related email notification for this thread.
[5]: https://learn.microsoft.com/en-us/answers/articles/67444/email-notifications.html