[.net] Deadlock error

Started by
1 comment, last by stonemetal 16 years, 4 months ago
Hi, I am developing a win apps in C#.Net2. I was importing a Excel file (which contains almost 5000 names) to a listbox. After loading all the 5000 names to the listbox, then i tried to save it to a sqlite database, an error - "ContextSwitchDeadlock was detected" occured. The error message says as follows: The CLR has been unable to transition from COM context 0x1a0c50 to COM context 0x1a0dc0 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. What is this?? How can i solve this problem ????? Thanks in advance,
Advertisement
In essence what it's telling you is that something you did attempted to wait on an object handle using one of the wait functions that do not pump messages. It then informed you of one of the correct wait functions to use.

In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.

or as it also states you did something that takes a really long time from a gui thread so your app is going to lock up for however long it takes. Sounds like you need to use a transaction on your sqlite insert, because sqlite will automatically create a transaction for each insert you run if you don't create your own. When it does this it can cause a 100X slow down. to clarify if you wrote something like
for(.....)
{
do insert
}

sqlite will do something like

for(....){
start transaction
do insert
finish transaction
}
which is really slow
so what you want to do is
start transaction
for(....)
{
do insert
}
finish transaction

to speed it up.

This topic is closed to new replies.

Advertisement