How do i give a thread a value??

G

GERM

Hi,
Is it in dotNet possible to give a starting Thread a value on
startup??


Thread* connecttoserver = new Thread(new ThreadStart(0,
ConnectToServer));
connecttoserver->Start();
...

static void ConnectToServer(){}


^^that works fine,
but when i try to give a value to ConnectToServer it come an error

[code:1:762980b63d]
int i = 0;
Thread* connecttoserver = new Thread(new ThreadStart(0,
ConnectToServer(i)));
connecttoserver->Start();
...

static void ConnectToServer(int access){}
[/code:1:762980b63d]

thx for help

PS: i know, i can no english :p
 
M

Michiel

Yes for some reason this works differently than in old-school C++ :p
You have to make the variable you pass a static member of the class instead,
then it'll work.
Like

static int i;

In function
i=0;

In the thread function i has the value 0.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top