Sign in to follow this  
softengg

[.net] Deadlock error

Recommended Posts

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,

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this