Ver Mensaje Individual
  #4  
Antiguo 03-02-2025
chenech chenech is offline
Miembro
 
Registrado: dic 2013
Posts: 138
Reputación: 13
chenech Va por buen camino
Un ejemplo bastante simple que cada 5 segundos actualiza un label con la hora, añade un botón y verás que sigue operativo mientras se va actualizando el label:
Código PHP:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include <System.Threading.hpp>
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponentOwner)
    : 
TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
    
_di_ITask tasks[1];
    
tasks[0] = TTask::Create([&] ()
    {
        
Prueba();
    });
    
tasks[0]->Start();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Prueba(void)
{
        
Sleep(5000);
        
Label1->Caption Time();
}
//--------------------------------------------------------------------------- 
Responder Con Cita