2 Replies - 7517 Views - Last Post: 08 August 2009 - 01:59 PM Rate Topic: -----

#1 gibson_junk  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 89
  • Joined: 24-July 09

System.threading in C++ works?

Posted 08 August 2009 - 01:30 PM

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
Is This A Good Question/Topic? 0
  • +

Replies To: System.threading in C++ works?

#2 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2250
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: System.threading in C++ works?

Posted 08 August 2009 - 01:33 PM

well you can find a basic example on MSDN here
Was This Post Helpful? 0
  • +
  • -

#3 gibson_junk  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 89
  • Joined: 24-July 09

Re: System.threading in C++ works?

Posted 08 August 2009 - 01:59 PM

View PostNickDMax, 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

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1