سلام
لطفا روش درست کرن و استفاده از thread ها وsemaphore ها رو توضیح بدین
ممنون
سلام
لطفا روش درست کرن و استفاده از thread ها وsemaphore ها رو توضیح بدین
ممنون
این حالت ساده استفاده از Tread
البته میتونی Sleep و Priority رو هم تنظیم کنی
thd1 : اسم ترد
Thread _thd1;
_thd1 = new Thread(new ThreadStart(MethodThd1));
_thdmove1.Start();
MethodThd1: اسم متدی که میخوای توی یک ترد اجرا شه
آن لحظه که تنها اعتبار کسی که مساله ای را مطرح کرده است، شما را در اشتباه بودن ایده هایتان قانع کرد،
آن لحظه،
لحظه وداع شما با دنیای خلاقیت و پیشرفت خواهد بود. . .
برنولی
code in C++ builder:
#include <vcl.h>
#include <conio.h>
#include <iostream.h>
#pragma hdrstop
//--------------------------------------------------------------------------
class MyThread : public TThread
{
private:
protected:
void __fastcall Execute();
public:
__fastcall MyThread(bool CreateSuspended);
};
//--------------------------------------------------------------------------
__fastcall MyThread::MyThread(bool CreateSuspended)
: TThread(CreateSuspended)
{
}
//--------------------------------------------------------------------------
void __fastcall MyThread::Execute()
{
cout << "\n ";
for ( int i = 0 ; i < 10000 ; i++ );
cout << "\nI am tread No:" << this->Handle;
}
//--------------------------------------------------------------------------
#pragma argsused
int main(int argc, char* argv[])
{
MyThread *t[6];
int i;
for ( i = 0 ; i < 6 ; i++ )
{
t[i] = new MyThread( true );
cout << "\n creating thread NO. " << t[i] -> Handle;
}
for ( i = 0 ; i < 6 ; i++ )
{
t[i] -> Priority = tpHighest;
t[i] -> Resume();
}
cout << "\n I AM MAIN THREAD...";
getch();
return 0;
}
اون وقت ربطش به سی شارپ چی بود؟
سلام دوست عزیز
این دو تا مقاله شاید به دردت بخوره.یکیشو که نمی دونم از کجا گرفتم که فارسی هستش.یکیش هم از کتاب Wrox Professional CSharp 2005 هستش.
Close your eyes, take a deep breath, click your heels three times, and say, "There's no better thing than Inversion of Control and Dependency Injection, generic specialization, the decorator pattern, chains of responsibilities, and extensible software."