When clicking button in dockable window to upload data in DataGrid today, found that multiple uploads will cause problem An ItemsControl is inconsistent with its item source. Later checking problem found it was due to multi-threading exception causing the problem.
Reason should be dockable pane and Revit itself are two processes. Data passing between main process and window caused process error, thus triggering the problem.

1
2
3
4
5
6
7
8
9
10
11
private ObservableCollection<ExternalProperity.ProjectMessageClass> _messages = new ObservableCollection<ExternalProperity.ProjectMessageClass>();
void UpdateItems(ExternalProperity.ProjectMessageClass message)
{

Dispatcher.BeginInvoke(DispatcherPriority.Background, new ParameterizedThreadStart(AddItem), message);

}
void AddItem(object message)
{
_messages.Add((ExternalProperity.ProjectMessageClass)message);
}

Reference blog address: Exception under multi-threading: An ItemsControl is inconsistent with its item source
Stackflow