Other Software > Developer's Corner
My Application...
Codebyte:
wow, tyvm! this is awesome and im understanding this for the most part! way cool, ty again!
Codebyte:
Alright, so status update... I wrote my first threaded program that uses 2 threads, 1 thread that accesses global variables and another thread that downloads files from a list of "Files to be downloaded" lol... This coding helped alot! I do have a question however, what did you use to drop in that coding for me to see? I wanted to upload a sample for people to see how it works in Borland C++ builder...
jgpaiva:
It's simple, CodeByte!
Just copy the code from your editor, then paste it on the reply box. Then select all the code, and press the # button, which will enclose the code in [code] tags.
PS: if you'd like to have syntax highlighting, press the # button, and then add =cpp to the [code], so that is looks like this:
[code=cpp]
int main void(){
whatever
}
[/code]
Codebyte:
thats way cool! ill upload the coding once I finish a basic template for multithreading in BCB 2007. ty for all the help guys!
Codebyte:
Here is a general idea of Threading for someone new to the concept...
Create a new project and add 2 Buttons, named Suspend and Resume... These will control the Thread using the OnClick() function.
Here is the coding I used along with BCB RAD Studio 2007:
(Keep in mind this is a sample template I wrote...)
--- Code: C++ ---//---------------------------------------------------------------------------#include <vcl.h>#pragma hdrstop #include "Unit1.h"//---------------------------------------------------------------------------#pragma package(smart_init)#pragma link "IdExplicitTLSClientServerBase"#pragma resource "*.dfm"TForm1 *Form1;HANDLE Thread; //THIS IS FOR THE THREAD//---------------------------------------------------------------------------DWORD WINAPI ThreadFunc(LPVOID Param){ //Tell the Thread what to do here}//---------------------------------------------------------------------------__fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner){ DWORD Id; Thread = CreateThread(0, 0, ThreadFunc, Form1->Handle, CREATE_SUSPENDED, &Id); if(!Thread) { ShowMessage("Cannot Create Thread!"); Application->Terminate(); }}//---------------------------------------------------------------------------void __fastcall TForm1::ResumeClick(TObject *Sender){ ResumeThread(Thread);}//---------------------------------------------------------------------------void __fastcall TForm1::SuspendClick(TObject *Sender){ SuspendThread(Thread); }//---------------------------------------------------------------------------
Ill have a sample of how to set priorities between threads soon, once I fully embrace the concept.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version