ComboBox takes too long to open (COMException Error)

Here is the situation with my problem:
I have one ListBoxwith two type elements MyClass.
MyClasshas a collection List<Column>.
Somewhere else in one window I have ComboBoxwith the columns selected MyClass.ColumnCollectionas ItemsSource.

This is where the problem begins:
The first time I open the ComboBox popup, everything is going well.
When I select another item in the ListBox (as well as changing the source of the ComboBox), it takes more than 10 seconds to open the popup. If it takes more than 60 seconds, I get the following error:

The CLR has been unable to transition from COM context 0xf13d90 to COM context 0xf13fe0 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations.

I searched for the error and wherever I came, it was advice to disable the ContextSwitchDeadlocks throw, which is not a solution at all!

I looked further and found the following COMException:

An event was unable to invoke any of the subscribers (Exception from HRESULT: 0x80040201)

I am not using threads / tasks or anything else, just binding to ComboBox.
I tried updating the ItemsSource while selecting a different item, but that didn't make any difference since it was already installed correctly.

I tried google for this error, but there seems to be no solution for this problem.
Microsoft has proposed a fix for this, but there is no download.

Code for ListBox:

    <ListBox Margin="468,30,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Height="420" Width="410"
                            ItemsSource="{Binding ElementName=Window, Path=MyClassItems}"
                            SelectedItem="{Binding ElementName=Window, Path=MyClassItem}"
                            DisplayMemberPath="Name" />

Code for ComboBox:

        <ComboBox Margin="580,490,0,0" Width="300"
                            VerticalAlignment="Top" HorizontalAlignment="Left" DisplayMemberPath="Name"
                            ItemsSource="{Binding ElementName=Window, Path=MyClassItem.Columns}"
                            SelectedItem="{Binding ElementName=Window, Path=MyClassItem.Column, Mode=OneWay}" SelectionChanged="SelectedColumn_SelectionChanged" />

SelectionChanged Event:

MyClassItem.Column = (sender as Combobox).SelectedValue as Column;

Questions:
Does anyone know how to prevent a COMException?

Update 1:
Added some Xaml code examples

Update 2:
Simplified Question (s)

3:
, - COM.
.

4:
ListBox , . , , comboBox 1 100 . ( ).

+3

All Articles