SashaBuilder3
Programmer
Hi!
I developed an app which performs some lengthy calculation. While running it does not respond to any event such as window resizing, window dragging, window content repainting and so on (sorry if my terminology does not look professional - I am just a beginner). I know that creating (multiple) threads is a solution but I don't know how to do this.
Here is the project (very simplified version of the real program) created in Borland C Builder 3. I placed a panel on the form and a button on the panel. Clicking the button starts the whole process.
Can anyone demonstrate on this simple example how to solve the problem?
Thanks in advance!
SashaBuilder3
//***********header file ***************
#ifndef pr8H
#define pr8H
//---------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ExtCtrls.hpp>
//---------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TPanel *Panel1;
TButton *btnStart;
void __fastcall btnStartClick(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//----------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------
#endif
//***********main file*************
#include <vcl.h>
#pragma hdrstop
#include "pr8.h"
#include <stdlib.h>
//-------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//--------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------
void __fastcall TForm1::btnStartClick(TObject *Sender)
{
int x,y;
long i,j;
for(i=0;i<1000000;i++)
for(j=0;j<1000000;j++)
{
x=random(600);
y=random(400)+50;
Canvas->TextOut(x,y,"Hello"
}
}
//---------------------------------------------------
I developed an app which performs some lengthy calculation. While running it does not respond to any event such as window resizing, window dragging, window content repainting and so on (sorry if my terminology does not look professional - I am just a beginner). I know that creating (multiple) threads is a solution but I don't know how to do this.
Here is the project (very simplified version of the real program) created in Borland C Builder 3. I placed a panel on the form and a button on the panel. Clicking the button starts the whole process.
Can anyone demonstrate on this simple example how to solve the problem?
Thanks in advance!
SashaBuilder3
//***********header file ***************
#ifndef pr8H
#define pr8H
//---------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ExtCtrls.hpp>
//---------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TPanel *Panel1;
TButton *btnStart;
void __fastcall btnStartClick(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//----------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------
#endif
//***********main file*************
#include <vcl.h>
#pragma hdrstop
#include "pr8.h"
#include <stdlib.h>
//-------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//--------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------
void __fastcall TForm1::btnStartClick(TObject *Sender)
{
int x,y;
long i,j;
for(i=0;i<1000000;i++)
for(j=0;j<1000000;j++)
{
x=random(600);
y=random(400)+50;
Canvas->TextOut(x,y,"Hello"
}
}
//---------------------------------------------------