Hi Wilfried,

I've already done this. Thank you and Francois and Dod for the responses.

Have fun.
/Ionut

Wilfried Mestdagh wrote:
> Hello Ionut,
> 
> Change it like this:
> 
>  in the main function:
>  .....
>                  Rec := PrepareRec(true);
>                  Rec.AllDist := Rec.AllDist - Dist;
>                  Rec.count := RecCount;
>                  Send(@Rec, SizeOf(TRec));
>                  Query.Next;
>  .....
> 
>  in OnDataSent:
>  .....
>        if not Query.Eof then begin
>             Rec := PrepareRec(true);
>             Rec.AllDist := Rec.AllDist - Dist;
>             Rec.count := RecCount;
>             Send(@Rec, SizeOf(TRec));
>             Query.Next;
>        end;
>  .....
> 
> ---
> Rgds, Wilfried [TeamICS]
> http://www.overbyte.be/eng/overbyte/teamics.html
> http://www.mestdagh.biz
> 
> Monday, February 6, 2006, 11:26, Ionut Muntean wrote:
> 
> 
>>Hi Wilfried,
> 
> 
>>I've changed the code to this:
> 
> 
>>in tha main function:
>>.....
>>                Rec := PrepareRec(true);
>>                Rec.AllDist := Rec.AllDist - Dist;
>>                Rec.count := RecCount;
>>                Send(@Rec, SizeOf(TRec));
>>                Query.Next;
>>                repeat
>>                     ProcessMessages
>>                until SentOk;
>>.....
> 
> 
>>in OnDataSent:
>>.....
>>      if Query.Eof then
>>      begin
>>           SentOk := true;
>>           exit;
>>      end
>>      else
>>      begin
>>           Rec := PrepareRec(true);
>>           Rec.AllDist := Rec.AllDist - Dist;
>>           Rec.count := RecCount;
>>           Send(@Rec, SizeOf(TRec));
>>           Query.Next;
> 
> 
>>      end;
> 
> 
>>The code is still entering 2 times ... :(
> 
> 
>>/ Ionut Muntean
> 
> 
> 
>>Wilfried Mestdagh wrote:
>>
>>>Hello Ionut,
>>>
>>>
>>>
>>>>The code is executed from OnClientDataAvailable of an TWSocketServer.
>>>>When the execution reach the "repeat .. until SentOk", on 
>>>>ProcessMessages the code is reentered a second time.
>>>
>>>
>>>This is normal. When you start looping processmessages then your code
>>>can be reentered because messages ar pumped. This is also bad design.
>>>You can easy change your code event driven, just call Send there with
>>>the first record. On OnDataSent you send your next record, etc, as Dod
>>>already mentioned.
>>>
>>>---
>>>Rgds, Wilfried [TeamICS]
>>>http://www.overbyte.be/eng/overbyte/teamics.html
>>>http://www.mestdagh.biz
>>>
>>>Monday, February 6, 2006, 10:49, Ionut Muntean wrote:
>>>
>>>
>>>
>>>>Hi,
>>>>Please look at the code below.
>>>>.
>>>>.
>>>>.
>>>>     try
>>>>          try
>>>>               Query.Open;
>>>>               OnDataSent := DataWasSent;
>>>>               // DataWasSent sets "SentOk" to True
>>>>               while not Query.EOF do
>>>>               begin
>>>>                    Rec    := PrepareRec(true);
>>>>                    Rec.AllDist := Rec.AllDist - D;
>>>>                    Rec.Count := RecCount;
>>>>                    SentOk := false;
>>>>                    Send(@Rec, SizeOf(TRec));
>>>>                    repeat
>>>>                         ProcessMessages;
>>>>                    until SentOk;
>>>>                    Query.Next;
>>>>               end;
>>>>          except
>>>>               on E: Exception do
>>>>                    Display(ExecuteCommand1 - %s', [E.Message]);
>>>>          end
>>>>     finally
>>>>          Query.Close;
>>>>          OnDataSent := nil
>>>>     end;
>>>
>>>
>>>>The code is executed from OnClientDataAvailable of an TWSocketServer.
>>>>When the execution reach the "repeat .. until SentOk", on 
>>>>ProcessMessages the code is reentered a second time.
>>>
>>>
>>>>What am I doing wrong?
>>>
>>>
>>>>10x,
>>>>Ionut Muntean
>>>
>>>
> 
> 

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to