Problem with Thread


khuenguyen

Recommended Posts

Hi Admin,

I have a function with name "get_parameters(string btsID)". In this function, I acquire data from bts. From other sequence, I create a thread as below:

StartThread("get_parameters(bts_name)","GetParameter",1)

but, In function "get_parameters(string btsID)", it doesn't receive argument that I send and thread is stopped immediately.

but, if I run function normally, example, I call it as below:

get_parameters(bts_name)

it will run normal.

How I can solve this problem?

Thanks in advance.

Link to comment
Share on other sites

You can't pass parameters when starting a thread. This is a limitation of Windows. You pretty much have to use a global variable, set it before starting the thread, then have the thread get the value and store it somewhere locally. To ensure it gets it, have the thread set the value back to some invalid value (like -999), and then before you start another thread, wait for the value to go to -999.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.