![]() |
![]() |
| Paypal | FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
|||||||
| Registrarse | FAQ | Miembros | Calendario | Guía de estilo | Buscar | Temas de Hoy | Marcar Foros Como Leídos |
![]() |
|
|
Herramientas | Buscar en Tema | Desplegado |
|
|
|
#1
|
|||
|
|||
|
si, rutas es el nombre de la tabla y un string que me trae las rutas que voy a buscar en la tabla rutas...
cuando con F7 sale del procedimiento no desaparece el hilo en memoria.. sigue con la misma dirección... y como he creado 10 hilos del mismo tipo hilo.. aparecen los 10 con el mimo numero en memoria... y cuando intenta volver sobre el primer hilo ahi es cuando sale el error... |
|
#2
|
|||
|
|||
|
entonces...cuando se termina el hilo, lo destruyes, y no lo vuelves a crear aunque si lo vuelves a llamar...es eso?
|
|
#3
|
|||
|
|||
|
Gracias por tu ayuda...
no he entendido muy bien lo de los hilos... esos hilos deben destruirse o deben quedar alli latentes... la idea final es que se actualicen constantemente las casillas (cajones o stringridbox) con las rutas... y no le tengo nada que los destruya... no he podido entender si es que no puedo definir tantos hilos del mismo tipo o si falta algo para que cuando intenta utilizar el hilo definido no marque el error... o si es que no se hace asi... |
|
#4
|
|||
|
|||
|
perdon son checklistbox con las rutas... y progressbar para ver que lo esta haciendo constantemente...
|
|
#5
|
|||
|
|||
|
ok pero estaria bien que me contestaras algunas de las preguntas que te he hecho, porque sino, seguimos estando igual :
- creas (metodo create) correctamente el hilo? prueba de poner antes del primer try en .execute : if (self) = nil then Showmessage('no asignado') a ver si te salta este mensaje - creas y destruyes correctamente el query? - es posible que una vez terminado el hilo, lo destruyas y luego lo vuelvas a llamar sin haberlo recreado? tal como te dije, a estas alturas si pusieras el codigo entero (o adjuntado) del metodo donde te salta la excepcion... y del .create tambien. venga saludos y suerte |
|
#6
|
|||
|
|||
|
y hilo1, hilo2, etc... los creas? haces hilo1 := Thilomuestra_Estado.create(checkbox1,1)?
|
|
#7
|
|||
|
|||
|
oye gracias...es un codigo al que le hago mantenimiento y no cabe...... revise como me dijiste y separé el código de los hilos .......
parte i unit Unit6; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ComCtrls, StdCtrls,inifiles, ExtCtrls, CheckLst,QDialogs, Buttons,math, Grids, DBGrids, Psock, NMFtp, Menus, Mask, FileCtrl, SBSftpCommon, SBSimpleSftp, SBX509, SBCustomCertStorage, SBPGPKeys,SBSSHKeyStorage,SBSSHConstants, SBUtils,DateUtils,registry,db,dbtables; const SFTP_BLOCK_SIZE = $10000; type Tordenesdias = array[1..7] of string; type Thilo_mostrandoestados = class(TThread) private FBox: TCheckListBox; Fcajon,mensaje,codruta,accion,tipo_de_sinc : String; // estadocomparando : integer; protected procedure Execute; override; procedure MostrarProgreso; procedure MostrarProgreso2; public constructor Create(Box: TCheckListBox;cajon : string); // destructor Destroy; override; end; type Thilo_mostrandoestados2 = class(TThread) private FBox: TStringGrid; Fcajon,mensaje,codruta,accion,tipo_de_sinc : String; estadocomparando : integer; protected procedure Execute; override; procedure MostrarProgreso; procedure MostrarProgreso2; public constructor Create(Box: TStringGrid;cajon : string); end; type TForm6 = class(TForm) PageControl1: TPageControl; TabSheet1: TTabSheet; StringGrid3: TStringGrid; StringGrid2: TStringGrid; CheckListBox2: TCheckListBox; CheckListBox6: TCheckListBox; CheckListBox3: TCheckListBox; CheckListBox5: TCheckListBox; CheckListBox4: TCheckListBox; CheckListBox7: TCheckListBox; CheckListBox1: TCheckListBox; SpeedButton28: TSpeedButton; ProgressBar10: TProgressBar; ProgressBar7: TProgressBar; ProgressBar6: TProgressBar; ProgressBar8: TProgressBar; ProgressBar9: TProgressBar; ProgressBar5: TProgressBar; ProgressBar4: TProgressBar; ProgressBar1: TProgressBar; StringGrid5: TStringGrid; Memomostrarhilo: TMemo; BitBtn1: TBitBtn; procedure FormActivate(Sender: TObject); procedure FormShow(Sender: TObject); procedure SpeedButton28Click(Sender: TObject); procedure listarrutas; procedure insertarpaso(ruta,paso,tipoproceso,agentes : string); function rutas_en_cajones(posiciones : Tstrings): string; function aumentar(barra : TProgressBar) : boolean; procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure BitBtn1Click(Sender: TObject); private { Private declarations } public hilo0 : Thilo_mostrandoestados2; hilo1,hilo2,hilo3,hilo4,hilo5,hilo6,hilo9 : Thilo_mostrandoestados; { Public declarations } end; var Form6: TForm6; implementation uses Unit2, Unit3; {$R *.dfm} procedure TForm6.FormActivate(Sender: TObject); begin hilo0.Resume; hilo1.Resume; hilo2.Resume; hilo3.Resume; hilo4.Resume; hilo5.Resume; hilo6.Resume; hilo9.Resume; end; procedure TForm6.FormShow(Sender: TObject); begin StringGrid3.Cells[0,0] := 'Ruta'; StringGrid3.Cells[1,0] := 'P'; StringGrid3.Cells[2,0] := 'A'; StringGrid3.Cells[3,0] := 'E'; end; procedure TForm6.SpeedButton28Click(Sender: TObject); begin listarrutas; hilo0.Resume; hilo1.Resume; hilo2.Resume; hilo3.Resume; hilo4.Resume; hilo5.Resume; hilo6.Resume; hilo9.Resume; end; procedure TForm6.listarrutas; var i,j,verificador : integer; primero : boolean; begin dt.qbusca.Active := false; dt.qbusca.SQL.Clear; dt.qbusca.SQL.Add('select count(*) as contador from sincronizadas '); dt.qbusca.Active := true; dt.qbusca.First; verificador := dt.qbusca.FieldByName('contador').AsInteger; if verificador = 0 then begin // inicia de ceros for i := 0 to StringGrid2.RowCount - 1 do begin for j := 0 to StringGrid2.ColCount - 1 do begin StringGrid2.Cells[j,i] := ''; end; end; dt.qbusca.Active := false; dt.qbusca.SQL.Clear; dt.qbusca.SQL.Add('select codigo from ruta where tienehh = "s" and activo = "1" and modem = "n" order by codigo '); try dt.qbusca.Active := true; except dt.qbusca.SQL.Clear; dt.qbusca.SQL.Add('select codigo from ruta where tienehh = "s" and activo = "1" order by codigo '); dt.qbusca.Active := true; end; dt.qbusca.First; StringGrid2.RowCount := dt.qbusca.RecordCount; for i := 0 to dt.qbusca.RecordCount - 1 do begin StringGrid2.Cells[0,i] := dt.qbusca.fieldbyname('codigo').AsString; StringGrid2.Cells[1,i] := ''; insertarpaso(dt.qbusca.fieldbyname('codigo').AsString,'0','-','-'); dt.qbusca.Next; end; StringGrid2.Enabled := true; //creartablashh; end //no es nuevo else begin // dt.qbusca.Active := false; dt.qbusca.SQL.Clear; dt.qbusca.SQL.Add(' select * from sincronizadas '); dt.qbusca.Active := true; dt.qbusca.First; StringGrid2.RowCount := 0; primero := true; CheckListBox1.Items.Clear; CheckListBox2.Items.Clear; CheckListBox3.Items.Clear; CheckListBox4.Items.Clear; CheckListBox5.Items.Clear; CheckListBox6.Items.Clear; CheckListBox7.Items.Clear; // CheckListBox10.Items.Clear; // CheckListBox11.Items.Clear; for i := 0 to StringGrid2.RowCount - 1 do begin for j := 0 to StringGrid2.ColCount - 1 do begin StringGrid2.Cells[j,i] := ''; end; end; for i := 0 to StringGrid5.RowCount - 1 do begin for j := 0 to StringGrid5.ColCount - 1 do begin StringGrid5.Cells[j,i] := ''; end; end; StringGrid5.RowCount := dt.qbusca.RecordCount; for i := 0 to dt.qbusca.RecordCount - 1 do begin StringGrid5.Cells[0,i] := dt.qbusca.FieldByName('codruta').AsString; StringGrid5.Cells[1,i] := dt.qbusca.FieldByName('tipo_de_sinc').AsString; if dt.qbusca.FieldByName('estado').AsInteger = 0 then begin if primero then begin StringGrid2.Cells[0,StringGrid2.RowCount - 1] := dt.qbusca.FieldByName('codruta').AsString; StringGrid2.Cells[1,StringGrid2.RowCount - 1] := ''; primero := false; end else begin StringGrid2.RowCount := StringGrid2.RowCount + 1; StringGrid2.Cells[0,StringGrid2.RowCount - 1] := dt.qbusca.FieldByName('codruta').AsString; StringGrid2.Cells[1,StringGrid2.RowCount - 1] := ''; end; end else if dt.qbusca.FieldByName('estado').AsInteger = 1 then begin CheckListBox2.Items.Add(dt.qbusca.FieldByName('codruta').AsString); end else if dt.qbusca.FieldByName('estado').AsInteger = 2 then begin CheckListBox6.Items.Add(dt.qbusca.FieldByName('codruta').AsString); end else if dt.qbusca.FieldByName('estado').AsInteger = 3 then begin CheckListBox3.Items.Add(dt.qbusca.FieldByName('codruta').AsString); end else if dt.qbusca.FieldByName('estado').AsInteger = 4 then begin CheckListBox5.Items.Add(dt.qbusca.FieldByName('codruta').AsString); end else if dt.qbusca.FieldByName('estado').AsInteger = 5 then begin CheckListBox4.Items.Add(dt.qbusca.FieldByName('codruta').AsString); end else if dt.qbusca.FieldByName('estado').AsInteger = 6 then begin CheckListBox7.Items.Add(dt.qbusca.FieldByName('codruta').AsString); end else if dt.qbusca.FieldByName('estado').AsInteger = 7 then begin CheckListBox1.Items.Add(dt.qbusca.FieldByName('codruta').AsString); end; dt.qbusca.Next; end; end; dt.qbusca.Active := false; dt.qbusca.SQL.Clear; dt.qbusca.SQL.Add(' select count(r.codigo) as contador from ruta r left join sincronizadas s on r.codigo = s.codruta '); dt.qbusca.SQL.Add(' where s.codruta is null and r.tienehh = "s" and r.modem = "n" '); try dt.qbusca.Active := true; except dt.qbusca.SQL.Clear; dt.qbusca.SQL.Add(' select count(r.codigo) as contador from ruta r left join sincronizadas s on r.codigo = s.codruta '); dt.qbusca.SQL.Add(' where s.codruta is null and r.tienehh = "s" '); dt.qbusca.Active := true; end; dt.qbusca.First; verificador := dt.qbusca.FieldByName('contador').AsInteger; if verificador > 0 then begin // showmessage('13'); dt.qins.Active := false; dt.qins.SQL.Clear; dt.qins.SQL.Add(' insert into sincronizadas '); dt.qins.SQL.Add(' select r.codigo,"0","-","-" from ruta r left join sincronizadas s on r.codigo = s.codruta '); dt.qins.SQL.Add(' where s.codruta is null and r.tienehh = "s" and r.modem = "n" '); try dt.qins.ExecSQL; except dt.qins.SQL.Add(' insert into sincronizadas '); dt.qins.SQL.Add(' select r.codigo,"0","-","-" from ruta r left join sincronizadas s on r.codigo = s.codruta '); dt.qins.SQL.Add(' where s.codruta is null and r.tienehh = "s" '); dt.qins.ExecSQL; end; ShowMessage('ESTA APLICACION HA DETECTADO RUTAS NUEVAS, SE CERRARA... INGRESE NUEVAMENTE..'); Application.Terminate; end; if not Assigned(hilo0) then hilo0 := Thilo_mostrandoestados2.Create(StringGrid2,'0'); if not Assigned(hilo1) then hilo1 := Thilo_mostrandoestados.Create(CheckListBox2,'1'); if not Assigned(hilo2) then hilo2 := Thilo_mostrandoestados.Create(CheckListBox6,'2'); if not Assigned(hilo3) then hilo3 := Thilo_mostrandoestados.Create(CheckListBox3,'3'); if not Assigned(hilo4) then hilo4 := Thilo_mostrandoestados.Create(CheckListBox5,'4'); if not Assigned(hilo5) then hilo5 := Thilo_mostrandoestados.Create(CheckListBox4,'5'); if not Assigned(hilo6) then hilo6 := Thilo_mostrandoestados.Create(CheckListBox7,'6'); if not Assigned(hilo9) then hilo9 := Thilo_mostrandoestados.Create(CheckListBox1,'7'); end; |
![]() |
| Herramientas | Buscar en Tema |
| Desplegado | |
|
|
Temas Similares
|
||||
| Tema | Autor | Foro | Respuestas | Último mensaje |
| Indy y Threads | PeLuCa | Internet | 20 | 13-01-2011 00:42:21 |
| Error in my_thread_global_end(): 4 threads didn't exit ??? | foetus | PHP | 2 | 26-10-2007 18:52:16 |
| uso de threads | JULIPO | API de Windows | 2 | 25-07-2007 16:09:06 |
| Error: Delphi 2006 + Debugger + Threads | xEsk | Varios | 0 | 16-02-2007 16:03:19 |
| Threads y transacciones | anduj | Conexión con bases de datos | 5 | 12-07-2005 20:31:40 |
|