I have written an application for a client. This is my first time using Linq to SQL. The application runs and closes normally unless I do a very large query to a datagridview. If I do a query that brings ~500 records into the datagridview everything works normally. If the query returns ~2000 records it takes a couple of seconds to close the application. If I query ~8000 records it takes 10-15 seconds to close. The full query of 24000 records takes several minutes to close the form. It always hangs at components.Dispose() in the form Dispose method.
The main Linq to SQL query is wrapped in a "using" statement and is used as the datasource for a bindingsource linked to a datagridview. It appears that the data context and the bindingsource are both already disposed before the code where the application hangs. I tried disposing the datagridview that held all the records manually before the call to components.dispose() and it disposes easily. I can't figure out what component it is that is hanging the dispose method, and when I try to step through it in debug in VS2008 it steps over the actual dispose code so I can't see which component hangs it.
Anything that points me in a new direction would be appreciated.
PS - I just remembered. Even if I run a small query subsequent to a large query so that the datagridview only has a few records in it at the time it is closed, it still takes just as long to close. It does not matter how many records are currently bound to the control. Once a large query is performed, it will take a long time to close that session.