Board index » delphi » dbexpress in thread locking application
halfbaked
![]() Delphi Developer |
dbexpress in thread locking application2004-05-22 06:32:59 PM delphi234 Im using a thread which creates several TSQLQuerys that all use a single connection from the Data Module. and operations on the TSQLQueries are done within critical sections, however when freeing the thread and destroying the TSQLQueries the application locks up - the following lines is the output from MadExcept. 77f82870 ntdll.dll NtWaitForSingleObject < - it never returns from this 77f88225 ntdll.dll RtlpWaitForCriticalSection 00407290 Flow.exe System @IntfClear 004fb7ca Flow.exe SqlExpr TCustomSQLDataSet.FreeCursor I use the following (simplified) code to create and free the worker thread. (worker thread properties are = FreeOnTerminate = False, CreateSuspended = False) FThread := TActionThread.Create(FActionID); WaitForSingleObject(FThread.Handle, INFINITE); FreeAndNil(FThread); //<-- during the freeing of the thread it frees the queries which cause the lock i know this looks like it defeats the purpose of the thread becuase im waiting for it after creating it, but this is also run within a another thread on a timed basis. what is the correct way to use the TSQLQuery from within a thread? do i need a seperate TSQLConnection as a property of the thread? any ideas would be much appreciated main thread ($5f0): 77f82870 ntdll.dll NtWaitForSingleObject <-lock up occurs here when the wait never returns. 77f88225 ntdll.dll RtlpWaitForCriticalSection 00407290 Flow.exe System @IntfClear 004fb7ca Flow.exe SqlExpr TCustomSQLDataSet.FreeCursor 004eb596 Flow.exe DB 8901 TDataSet.CloseCursor 004fb7b0 Flow.exe SqlExpr TCustomSQLDataSet.CloseCursor 004eb45f Flow.exe DB 8853 TDataSet.SetActive 004eb264 Flow.exe DB 8805 TDataSet.Close 004fb15d Flow.exe SqlExpr TCustomSQLDataSet.Destroy 004ffe59 Flow.exe SqlExpr TSQLQuery.Destroy 004043dc Flow.exe System TObject.Free 0077edd3 Flow.exe classFloModule 358 TFloModule.Destroy 0064f641 Flow.exe ClassFloDBCon 92 TFloDBCon.Destroy 004043dc Flow.exe System TObject.Free 007775cc Flow.exe ClassFloDataSource 522 TFloDataSource.Destroy 006803d6 Flow.exe ClassFloFileSource 206 TFloFileSource.destroy |