OnPaint: System.InvalidOperationException

Can you help me in knowing the reason of this exception because I’m not able to debug it as it doesn’t happen in my classes.
OnPaint: System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
I have code running in a separate thread that is modifying the document, by adding or removing Gotext objects to the document.

since the Controls of my Form are painting and handling events on their own thread. I could not remove or add those, Can any body help in synchronizing with goview or solve this problem.
Thanks in advance

The easiest way to synchronize, for most applications, is to make sure the code that adds or removes objects from the document executes in the GoView’s thread.

First, move that document-modifying code into a separate method.
Second, implement a method that checks the Control.InvokeRequired property. If true, call Control.Invoke to call your method to modify the document; if false, you can call your document-modifying method immediately.
Third, have all the original callers of your modifying code call this second method, not the document-modifying method directly.