Hi i need to know how to use
System.threading in C++ console to doing multiple threads. i look for tutorial or sample code but find none. any one help with how to do or a example code of a console looping through 2 threads or something
System.threading in C++ works?
Page 1 of 12 Replies - 5719 Views - Last Post: 08 August 2009 - 01:59 PM
Replies To: System.threading in C++ works?
#3
Re: System.threading in C++ works?
Posted 08 August 2009 - 01:59 PM
NickDMax, on 8 Aug, 2009 - 12:33 PM, said:
well you can find a basic example on MSDN here
i have some code here but i get these errors C++ console app btw
1>.\Main.cpp(28) : error C3145: 'ts1' : global or static variable may not have managed type 'System::Threading::ThreadStart ^'
1> may not declare a global or static variable, or a member of a native type that refers to objects in the gc heap
1>.\Main.cpp(29) : error C3145: 't1' : global or static variable may not have managed type 'System::Threading::Thread'
1> may not declare a global or static variable, or a member of a native type that refers to objects in the gc heap
1>.\Main.cpp(29) : error C2512: 'System::Threading::Thread::Thread' : no appropriate default constructor available
1>.\Main.cpp(61) : error C2664: 'System::Threading::Thread::Thread(System::Threading::ThreadStart ^)' : cannot convert parameter 1 from 'System::Threading::Thread ^' to 'System::Threading::ThreadStart ^'
1> No user-defined-conversion operator available, or
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
#include <iostream>
#include <windows.h>
#include "Functions.h"
#include "Memory.h"
using namespace System;
using namespace System::Threading;
using namespace std;
const int Swift = 16320; // Swift Speed
const int Normal = 16256; // Normal Speed
void Typing()
{
if(Yes == 1)
{
ConsoleWrite("YesYesYes");
}
}
ThreadStart^ ts1;
Thread t1;
int main()
{
if (GetHandle("SoftsCare"))
{
InitializeAddresses();
while (isLogged())
{
bool keyWasPressed = false;
while(true)
{
if (GetAsyncKeyState(VK_DELETE))
{
ThreadStart^ ts1 = gcnew ThreadStart(Typing);
Thread t1 = gcnew Thread(ts1);
t1.Start();
}
CloseHandle(ProcessHandle);
system("pause");
return 0;
}
This post has been edited by gibson_junk: 08 August 2009 - 02:51 PM
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote




|