[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Jaan

10/6/2003 11:29:00 PM

Coming from the world of unix, I'm looking for a C#
fucntion that does as the unix thr_self() function does.

For those of you who arent familiar with that function, I
basically need a method of letting a child thread obtain
a unique thread id.

I simply want to print a message to the console and i'd
like the message to contain a unique id for each thread
so I can tell which thread is doing what.

Any way to do this?
I've seen the thread name property, but how does the
child thread know which one is his. assuming there are
more than 2-3 threads?

Help please. (remember, simple is the operative word
here.)
Thanks for your time.

2 Answers

Jaan

10/6/2003 11:46:00 PM

0

Nevermind, I found it.
System.Threading.Thread.CurrentThread.Name

In the parent thread, you just name your threads and in
the child threads, you look at the property:
System.Threading.Thread.CurrentThread.Name


>-----Original Message-----
>Coming from the world of unix, I'm looking for a C#
>fucntion that does as the unix thr_self() function does.
>
>For those of you who arent familiar with that function,
I
>basically need a method of letting a child thread obtain
>a unique thread id.
>
>I simply want to print a message to the console and i'd
>like the message to contain a unique id for each thread
>so I can tell which thread is doing what.
>
>Any way to do this?
>I've seen the thread name property, but how does the
>child thread know which one is his. assuming there are
>more than 2-3 threads?
>
>Help please. (remember, simple is the operative word
>here.)
>Thanks for your time.
>
>.
>

Lloyd Dupont

10/7/2003 12:33:00 AM

0

I suspect
System.Threading.Thread.CurrentThread.GetHashCode() would be even better for
you !

"Jaan" <jrettt@hotttamail.com> wrote in message
news:0a9901c38c64$01c03da0$a101280a@phx.gbl...
> Nevermind, I found it.
> System.Threading.Thread.CurrentThread.Name
>
> In the parent thread, you just name your threads and in
> the child threads, you look at the property:
> System.Threading.Thread.CurrentThread.Name
>
>
> >-----Original Message-----
> >Coming from the world of unix, I'm looking for a C#
> >fucntion that does as the unix thr_self() function does.
> >
> >For those of you who arent familiar with that function,
> I
> >basically need a method of letting a child thread obtain
> >a unique thread id.
> >
> >I simply want to print a message to the console and i'd
> >like the message to contain a unique id for each thread
> >so I can tell which thread is doing what.
> >
> >Any way to do this?
> >I've seen the thread name property, but how does the
> >child thread know which one is his. assuming there are
> >more than 2-3 threads?
> >
> >Help please. (remember, simple is the operative word
> >here.)
> >Thanks for your time.
> >
> >.
> >