Bonjours a tous,
essayant d'utiliser les Threads avec Visual studio 2005,
j'essaie de faire marcher un petit programe trouver sur les tuto de developpez.com:http://www.developpez.com/upload/faqcsharp/?page=thread
Donc m'etant inspirer du deuxieme programme j'ai ecris le suivant:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41 #include"addition.h" // [C++] // Compile using /clr option. #using<mscorlib.dll> usingnamespace System; usingnamespace System::Threading; class addi { private: int _a; int _n; public: addi(int a, int n) { _a=a; _n=n; } void executeThread() { Console::WriteLine("Index : " + _a); Console::WriteLine("Message : " + _n); } }; int main() { Console::WriteLine(S"Main thread: Start a second thread."); addi test= new addi(5,1); Thread b=new Thread(new ThreadStart(0,test.executeThread)); b->Start(); // Console::WriteLine(); return 0; }
mais voila j'obtien plusieurs erreur et ayant tout essayer en changeant les pointeurs de partout je m'en sors pas..
QUelqu'un aurez une idée?
Merciii
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 ------ Build started: Project: threadtest, Configuration: Release Win32 ------ Compiling... main.cpp .\main.cpp(36) : error C2440: 'initializing' : cannot convert from 'addi *' to 'addi' No constructor could take the source type, or constructor overload resolution was ambiguous .\main.cpp(38) : error C3149: 'System::Threading::Thread' : cannot use this type here without a top-level '*' .\main.cpp(38) : error C3867: 'addi::executeThread': function call missing argument list; use '&addi::executeThread' to create a pointer to member .\main.cpp(38) : error C3350: 'System::Threading::ThreadStart' : a delegate constructor expects 2 argument(s) .\main.cpp(38) : error C2512: 'System::Threading::Thread::Thread' : no appropriate default constructor available .\main.cpp(39) : error C2819: type 'System::Threading::Thread' does not have an overloaded member 'operator ->' c:\windows\microsoft.net\framework\v2.0.50727\mscorlib.dll : see declaration of 'System::Threading::Thread' did you intend to use '.' instead? .\main.cpp(39) : error C2232: '->System::Threading::Thread::Start' : left operand has 'class' type, use '.' Build log was saved at "file://c:\Documents and Settings\Administrateur.TITANIUM\Mes documents\Visual Studio 2005\Projects\threadtest\threadtest\Release\BuildLog.htm" threadtest - 7 error(s), 0 warning(s)
Partager