Trying to multithread program. C++/CLI

Apr 11, 2013 at 1:08pm
Hey i'm trying to multithread my program in c++/cli but i'm having problems with creating the threads the code im using is:

1
2
3
4
5
6
private: Void startThread(){
 MoveProj.Velocity = Variables.Velocity;
  MoveProj.ProjectilePos = Projectile1.ProjectilePos;
 Thread^ MotionThread1 = gcnew Thread(gcnew ParameterizedThreadStart(MoveProj ,MotionThread::MoveProjectile));
Thread^ MainThread = gcnew Thread(gcnew ThreadStart());
 }


but i'm getting the errors

Error	44	error C3350: 'System::Threading::ParameterizedThreadStart' : a delegate constructor expects 2 argument(s)	c:\users\gaz\documents\visual studio 2012\projects\projectilemotion\projectilemotion\Simulation.h	344
Error	89	error C3350: 'System::Threading::ParameterizedThreadStart' : a delegate constructor expects 2 argument(s)	c:\users\gaz\documents\visual studio 2012\projects\projectilemotion\projectilemotion\Simulation.h	344
Error	45	error C3350: 'System::Threading::ThreadStart' : a delegate constructor expects 2 argument(s)	c:\users\gaz\documents\visual studio 2012\projects\projectilemotion\projectilemotion\Simulation.h	345
Error	90	error C3350: 'System::Threading::ThreadStart' : a delegate constructor expects 2 argument(s)	c:\users\gaz\documents\visual studio 2012\projects\projectilemotion\projectilemotion\Simulation.h	345
Error	43	error C3867: 'MotionThread::MoveProjectile': function call missing argument list; use '&MotionThread::MoveProjectile' to create a pointer to member	c:\users\gaz\documents\visual studio 2012\projects\projectilemotion\projectilemotion\Simulation.h	344
Error	88	error C3867: 'MotionThread::MoveProjectile': function call missing argument list; use '&MotionThread::MoveProjectile' to create a pointer to member	c:\users\gaz\documents\visual studio 2012\projects\projectilemotion\projectilemotion\Simulation.h	344


any help with this would be a great help as its for my college(British so senior year for americans i think) computing project and my tutor wants it in relatively soon.
Last edited on Apr 11, 2013 at 1:43pm
Apr 11, 2013 at 1:49pm
The error messages are clear enough, Constructors you are calling as for example 'System::Threading::ParameterizedThreadStart' or 'System::Threading::ThreadStart' require that to be specified 2 arguments
Apr 11, 2013 at 4:05pm
Yea but on the parametisedthreadstart I have 2 arguments and its LL hrowing up that error. I've tried all of the Microsoft examples just modified for my code and well none of it works. Obviously its something wrong with the way im coding it but I can't figure it out. But thankyou for replying :P
Apr 11, 2013 at 4:37pm
At last I do nt see that ThreadStart has two arguments

hread^ MainThread = gcnew Thread(gcnew ThreadStart());
Apr 11, 2013 at 5:15pm
well no Threadstart dosn't atm. but the paramtisedThreadStart does and is still giving the same error so i'm obviously doing something wrong but i can't figure it out.

https://gist.github.com/welsh4evr/5365988

Thats most of my code i wrote everything in .h files instead of .cpp files but i don't think it makes much difference. the .cpp files are pretty much empty apart from a few #includes
Last edited on Apr 11, 2013 at 6:46pm
Topic archived. No new replies allowed.