![]() |
![]() |
| 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 |
|
#2
|
||||
|
||||
|
Una manera stándar de usar hilos es de la foma API de GUINDOWS
#include <vcl.h> #pragma hdrstop //#include "ThreadFormUnit1.h" #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- HANDLE Thread; DWORD WINAPI ThreadFunc(LPVOID Param) { int i=0; while(true) { Form1->Label1->Caption=IntToStr(i); Sleep(100); i++; } } __fastcall TForm1::TForm1(TComponent* Owner): TForm(Owner) { randomize(); DWORD Id; Thread = CreateThread(0, 0, ThreadFunc, Form1->Handle, CREATE_SUSPENDED, &Id); if(!Thread) { ShowMessage("Error! Cannot create thread."); Application->Terminate(); } } void __fastcall TForm1::StartClick(TObject *) { ResumeThread(Thread); Start->Enabled = false; Stop->Enabled = true; } void __fastcall TForm1::StopClick(TObject *) { SuspendThread(Thread); Stop->Enabled = false; Start->Enabled = true; } //--------------------------------------------------------------------------- O S K R |
| Herramientas | Buscar en Tema |
| Desplegado | |
|
|
|