473,396 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Reference to a Thread -> ThreadID?

Hi all,

I'm currently storing a reference to the entire thread object in my
application. However, I'm wondering if there is a smaller object I can
point to such as an Integer ThreadID?

If there is such a thing as a ThreadID, is there a method I can use to
return the Thread object?

Thanks.
--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 21 '05 #1
4 2391
* Lucas Tam <RE********@rogers.com> scripsit:
I'm currently storing a reference to the entire thread object in my
application. However, I'm wondering if there is a smaller object I can
point to such as an Integer ThreadID?

If there is such a thing as a ThreadID, is there a method I can use to
return the Thread object?


Threads have IDs, but they are not exposed by the thread class.
Nevertheless, storing a reference to a thread object is very
lightweight.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #2
The Managed Thread class does not expose any thread ID property neither any
handle property which one can use. However, the GetHashCode can be used to
uniquely identify a thread. Here's some more info on this:

http://msdn.microsoft.com/library/de...oftwindows.asp

But ofcourse, thats not going to help you since there's no method in the
managed thread class of retrieving the Thread object from the hashcode (or
even from the threadid or thread handle) unless you store the
hashcode-thread pairs in a hashtable which defeats the whole purpose of
lightweight!

In anycase I don't think hanging onto a thread object is that 'heavy' as
such. Compared to some of the GDI+ objects, these are pretty ligthweight and
shouldn't be much of a problem.

hope this helps..
Imran.

"Lucas Tam" <RE********@rogers.com> wrote in message
news:Xn***************************@140.99.99.130.. .
Hi all,

I'm currently storing a reference to the entire thread object in my
application. However, I'm wondering if there is a smaller object I can
point to such as an Integer ThreadID?

If there is such a thing as a ThreadID, is there a method I can use to
return the Thread object?

Thanks.
--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/

Nov 21 '05 #3
Lucas,
I'm currently storing a reference to the entire thread object in my
application. However, I'm wondering if there is a smaller object I can
point to such as an Integer ThreadID?


On 32-bit systems, Object refernces are 32 bits, just like an int. So
you'll not save anything by using an int instead.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 21 '05 #4
hi***************@gmx.at (Herfried K. Wagner [MVP]) wrote in
news:O7*************@TK2MSFTNGP11.phx.gbl:
Nevertheless, storing a reference to a thread object is very
lightweight.


Thanks for the info : )

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: john smith | last post by:
If I create an object and pass it by reference to two other functions, and the other two function have separate threads must I worry about threadsafety? The two functions could modify the myCar...
9
by: Andy Chang | last post by:
Hi, If I have this function void DoSomething(int& index) { ::Sleep(10000); DoSomethingWith(index); } Is the variable index thread safe? Meaning that if I call this from two
0
by: erdem | last post by:
hi, i want to ask smt about databinding, threading etc. this is situation: lets say: i have a type dataset (name: "dsall") it has datatables table1 , table2 threre are adapters which fills...
5
by: Robert | last post by:
I have a series of web applications (configured as separate applications) on a server. There is a main application at the root and then several virtual directories that are independant...
2
by: Friskusen | last post by:
Hello VB.net programmers ! I'm just trying to understand what happens with an object which is initialised over and over again. The code fragment below illustrates my problem. This code is...
5
by: Mike Logan | last post by:
I used WSDL.exe to generate a client side web proxy for a web service, called the web service, got the results but an array returned by the web service is not in the results. However if I use...
7
by: Schroeder | last post by:
I have a DataSet that is cached deep down in a business layer object. Higher up, there's a merge being performed on that object and it very occassionaly throws a NullReferenceException deep down in...
51
by: Kuku | last post by:
What is the difference between a reference and a pointer?
15
by: mark.norgate | last post by:
Hello I want to create a reference to an object, so that changes to the referenced object are reflected in the other object. Like this: object o = 123; object p = o; o = 456;
0
by: raghudr | last post by:
Hi all, I am coding for displaying a splash screen until a big job is finished.I am getting an exception:only during the first start of the system.Rest all the time it is working fine. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.