Fórum acesso violetion - Thread #368483
16/02/2009
0
constructor TClientThread.Create(CreateSuspended: Boolean);
begin
//inherited Create(CreateSuspended);
inherited Create(true);
Self.Priority := tpIdle;
Self.FreeOnTerminate:= true;
end;
procedure TClientThread.Execute;
begin
// inherited;
[b:12b1b92828]with Form1 do //aqui da erro lembrando q este form1 qdo a propriedade ( FormStyle ) fica = fsMDIChild da erro, mas seu colocar fsNormal ( funciona normal ) [/b:12b1b92828]
alguem tem ideia de como posso resolver ISTO?
begin
if not IdTCPClient1.Connected then
exit;
repeat
cmd.text:= IdTCPClient1.ReadLn;
if trim(cmd.text) <> ´´ then
begin
if VerificaComando(cmd.text,´msg=´,true) then
Synchronize(ShowReceiveMsg)
else
if VerificaComando(cmd.text,´list_user=´,true) then
Synchronize(ListUsers)
else
if VerificaComando(cmd.text,´nick_existente=´,true) then
Synchronize(NickExistente)
else
if VerificaComando(cmd.text,´server_error=´,true) then
Synchronize(ShowServerError)
else
Synchronize(UnknowCmd);
end;
until not IdTCPClient1.Connected;
end;
{if not Terminated then
Terminate;}
end;
Walter Faria
Curtir tópico
+ 0Posts
16/02/2009
Woinch
Espero ter ajudado.
Gostei + 0
16/02/2009
Walter Faria
Obrigado.
Gostei + 0
17/02/2009
Woinch
{ TClientThread }
constructor TClientThread.Create(CreateSuspended: Boolean);
begin
//inherited Create(CreateSuspended);
inherited Create(true);
Self.Priority := tpIdle;
Self.FreeOnTerminate:= true;
end;
procedure TClientThread.Execute;
begin
Synchronize(Executa);
end;
procedure TClientThread.ExecutaThread;
begin
//inherited;
with Form1 do
begin
if not IdTCPClient1.Connected then
Exit;
repeat
cmd.text:= IdTCPClient1.ReadLn;
if trim(cmd.text) <> ´´ then
begin
if VerificaComando(cmd.text,´msg=´,true) then
ShowReceiveMsg
else if VerificaComando(cmd.text,´list_user=´,true) then
ListUsers
else if VerificaComando(cmd.text,´nick_existente=´,true) then
NickExistente
else if VerificaComando(cmd.text,´server_error=´,true) then
ShowServerError
else
UnknowCmd;
end;
until not IdTCPClient1.Connected;
end;
{if not Terminated then
Terminate;}
end;Talvez o problema não seja na Thread, mas sim no Form. Se não funcionar precisa de uma análise mais crítica.
Gostei + 0
18/02/2009
Ivanh
Um teste que pode ser feito eh passar o Form1 como parametro de criacao da Thread.
TClientThread = class(TThread) private FForm : TForm; end; constructor TClientThread.Create(CreateSuspended: Boolean, AForm : TForm); begin //inherited Create(CreateSuspended); inherited Create(true); Self.Priority := tpIdle; Self.FreeOnTerminate:= true; Self.FForm := AForm; end;
Gostei + 0
18/02/2009
Ivanh
Pode nao resolver seu problema, mas vai evitar alguns problemas futuros.
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)