Subject Re: Issue for process
Author heroes3lover
--- In, "Adam" <s3057043@...> wrote:
> --- In, "heroes3lover"
> <heroes3lover@> wrote:
> >
> > Hello everyone,
> > I got a problem.
> > Because some SQL is huge and make program no response for a
while, we
> > have to use thread to retrieve data, below is my
> > code,TSQLCompleteDataSetPlus is a component we inherited from
> > TSQLCompleteDataSet(this is component of dbexpressplus),
> > but when the process running to, sometimes the
> > program jammed, and looks like die, and cpu usage is 0%, I think
> > should be something wrong with thread safe issue, but I can not
> > out, cauz all stuff I created them in thread.
> > Is there anybody can figure out the possible issue?
> > Thanks very much.
> Firstly, if it is an insert / update / delete, there is the
> possibility of a 'lock conflict'. That means you have two or more
> transactions attempting to modify the same record at the same time,
> a snapshot transaction trying to modify a record that a newer
> transaction has modified. If you are using a WAIT transaction, your
> transaction will suspend until that other transaction commits or
> back. Try using NOWAIT in however that is represented by your
> connection components.
> Secondly, establishing a connection is not threadsafe, so you may
> to put a mutex around
> conInThread := TSQLConnection.Create(nil);
> Use OutputDebugString in the windows unit to send messages from
> your thread. Download DebugView from Microsoft (formerly
> and you can watch what is happenning. You are doing synchronise to
> write your logs at the moment, which is going to put a bottle neck
> there.
> Without knowing what state it is in when it freezes and not having
> time to analyse everything about your threading code, it makes sense
> to narrow down your problem to whether you are waiting for Firebird
> Delphi first.
> Adam

Thank you Adam,
Currently I only use Select in the thread, the reason is that
customers complaint about their white screen, said our program freeze
their laptop, so use one thread backgroud to do select stuff, and
main process wait for the thread terminated which can get rid of the
white screen.In fact, only one thread can running background, so I
can not imagine the connection can cause this problem, but I can try.