Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / June 2004

Tip: Looking for answers? Try searching our database.

How do i give a thread a value??

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
GERM - 10 Jun 2004 19:31 GMT
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
Michiel - 11 Jun 2004 08:39 GMT
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.

> Hi,
> Is it in dotNet possible to give a starting Thread a value on
[quoted text clipped - 28 lines]
>     ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
> ----------------------------------------------------------

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.