Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Thread.CurrentThread - How can it return object instance when it is static

Posted on 2005-05-07
6
Medium Priority
?
196 Views
Last Modified: 2006-11-18
Hello Friends,

In my casual reading, I came across that Thread.CurrentThread returns the current thread instance and this is a static read-only property. I don't understand it's implementation. If this is static, then how can it return object's instance? How would the property definition be written (there is no "this" here... right???) ?

I am sure I am missing something here... Please let me know ur suggestions...

Thanks
0
Comment
Question by:srinivas_vemla
  • 3
  • 3
6 Comments
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 13950852
public class foo() {
    public static foo CurrentFoo {
         return new foo(); //naturally it would be looking up the existant thread in a table but ...
    }
}


does this not return an instance of a foo from a static property?



0
 

Author Comment

by:srinivas_vemla
ID: 13950869
Yeah, it does return an instance... but does it return the "current" instance.... u know, how does the called function know who is calling, when it is static? I am confused on that point...
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 13950874
there is a static table out there that holds the threads ... it is using an OS call to get your thread object then returning it to you ...

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:srinivas_vemla
ID: 13950885
tx greg for your replies... I guess that answers my question... do u have any link that wud describe the static tables? that wud be great...
0
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 400 total points
ID: 13950963
It is stored by the CLR as they are logical threads not OS level threads in reality (it actually does some mapping internally) ...

to see the table for OS level threads ...

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdiagnosticsprocessclassthreadstopic.asp

Greg
0
 

Author Comment

by:srinivas_vemla
ID: 13951095
Thanks Greg,

thanks for the info...
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month13 days, 2 hours left to enroll

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question