Synopsis: | Always document from which thread an event handler is called |
Language: | C# |
Severity Level: | 9 |
Category: | Delegates and events |
Description: |
Some classes create a dedicated thread or use the Thread Pool to perform some work, and then raise an event when the work is done. The consequence of that is that an event handler is executed from another thread than the main thread. For such an event, the event handler must synchronize (ensure thread-safety) access to shared data (e.g. instance members). |