The current thread is attempting use a database object that is currently being used by another thread...

A sad story (with a happy ending)

A short post, on this potentially confusing error.  I remember some time ago spending much too long debugging an application with this error.  I knew that the Database was not thread safe and I was sure that I was explicitly disposing every Database I instantiated.  It was a fairly large application though so I kept second guessing myself.  Also this was in 8.1, before we had removed unnecessary use of IDisposable so it was more difficult than it should have been to run code analysis to work out what I was not disposing.  Finally, I tracked it down, it was not a Database object at all, at least not directly, it was a TrimMainObjectSearch!  Someone (trust me, not I) had used a TrimMainObjectSearch without disposing it.  At some later time the GC came along and attempted to clean it up, the TrimMainObjectSearch contains a reference to the Database and the GC was on a different thread, hence the error.

The moral of the story!

In versions of RM prior to 82 always explicitly dispose both your Database and TrimMainObjectSearch objects.