Ver Mensaje Individual
  #7  
Antiguo 07-03-2014
Avatar de aguml
aguml aguml is offline
Miembro
 
Registrado: may 2013
Posts: 885
Reputación: 12
aguml Va por buen camino
Eso ya me funciona pero el problema ahora es que si pongo:

Código:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "HiloDBG.h"
#include "Unit1.h"

#pragma package(smart_init)

//---------------------------------------------------------------------------

//   Important: Methods and properties of objects in VCL can only be
//   used in a method called using Synchronize, for example:
//
//      Synchronize(UpdateCaption);
//
//   where UpdateCaption could look like:
//
//      void __fastcall HDebugger::UpdateCaption()
//      {
//        Form1->Caption = "Updated in a thread";
//      }
//---------------------------------------------------------------------------

__fastcall HDebugger::HDebugger(bool CreateSuspended)
        : TThread(CreateSuspended)
{
        FreeOnTerminate = true;
        Suspended = false;
}
//---------------------------------------------------------------------------

void __fastcall HDebugger::Execute()
{
        //---- Place thread code here ----
        Synchronize(ActualizarDatos);
        //Synchronize((TThreadMethod)&ActualizarDatos);
}
//---------------------------------------------------------------------------

void __fastcall HDebugger::ActualizarDatos(void)
{
       int x = 0;
       while(x != 1){x = 0}
}
Y luego intento salir del hilo o pausarlo pues no responde e incluso se me queda congelada la ventana al intentar pausar el hilo o terminarlo con Terminated() o Suspend().
He intentado esto:

Código:
//Terminamos el hilo del debugger
        if(HiloDebugger != NULL)
        {
                HiloDebugger->Terminate();
                delete HiloDebugger;
        }
y tambien con esto:

Código:
//Terminamos el hilo del debugger
        if(HiloDebugger != NULL)
        {
                HiloDebugger->Suspended = true;
                HiloDebugger->Terminate();
                delete HiloDebugger;
        }
y poniendo en el bucle esto:

Código:
if(HiloDebugger->Suspended == true)
                        HiloDebugger->Suspend();
Pero sigue congelandose y no sale ni pausa el hilo y ademas nunca llega a entrar en el condicional o eso creo.
Responder Con Cita