Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread OT: Thread running twice
Thu, Oct 22 2009 1:41 PMPermanent Link

"Eduardo [HPro]"
Hi guys

I have a routine in a multithread DLL.

Sometimes I have some trouble with the code running twice for some users.

Example:

procedure X;
begin
       if Table.FindKey([key]) then begin
           Table.Edit;
           Table.FieldByName('X').AsInteger :=
Table.FieldByName('X').AsInteger + 1;
           Table.Post;
       end;
end;

If the initial value is 1 the correct value after the routine should be 2. I
have a log to this operation with something like below:

OldValue    NewValue
1                2
2                3
3                4

Sometimes I only run the procedure once and it will produce two rows in the
log table (like two threads runing for the same clients).

I wonder if someone could drives me to prevent this type of thing. It could
be a problem with threads ?

Eduardo

Thu, Oct 22 2009 1:47 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Eduardo,

<< I wonder if someone could drives me to prevent this type of thing. It
could be a problem with threads ? >>

The only way that I can think of this occurring is if you have threads
stepping on each other's objects because they are not properly isolated via
critical sections or separate objects.

BTW, have you ever sent me the source code to this project ?  This could be
related to your issue with index corruption.

--
Tim Young
Elevate Software
www.elevatesoft.com

Thu, Oct 22 2009 3:04 PMPermanent Link

"Eduardo [HPro]"
Tim

> BTW, have you ever sent me the source code to this project ?  This could
> be related to your issue with index corruption.
It was sent to your private e-mail

Eduardo

Thu, Oct 22 2009 7:28 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Eduardo,

<< It was sent to your private e-mail >>

Okay, I'll take a look.

Thanks,

--
Tim Young
Elevate Software
www.elevatesoft.com

Image