Francois PIETTE wrote:
> I also solved an issue when an exception is raised in the worker thread,
> outside of an TWSocket event handler (those exceptions are catched by
> OnBgException). When an exception is raised in the worker thread, it is
> catched, the clients are aborted, a new event OnThreadException is
> triggered and the thread is terminated.

It becomes more and more a very interisting class :)

I found one little problem, sorry my fault:

procedure TWSClientThread.DetachClient(Client: TWSocketThrdClient);
var
    I : Integer;
begin
    try
        if Assigned(Client) then
        try           
            Client.ThreadDetach;
=>          Client.FClientThread := nil;
        except    
=>          Client.FClientThread := nil;
        end;
    finally
<=      //Client.FClientThread := nil;
        I := FClients.IndexOf(Client);
        if I > -1 then
            FClients.Delete(I);
    end;
end;

I'm not sure whether it's OK to ignore an possible exception in
ThreadDetach or not, it _may_ be safe.
With your exception handling we could also let the exception thru in
order to terminate the thread?  

procedure TWSClientThread.DetachClient(Client: TWSocketThrdClient);
var
    I : Integer;
begin
    try
        if Assigned(Client) then
        try           
            Client.ThreadDetach;
        finally
            Client.FClientThread := nil;
        end;
    finally
        I := FClients.IndexOf(Client);
        if I > -1 then
            FClients.Delete(I);
    end;
end;

{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}

-- 
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