![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 | |
|
Professional Programmer
Join Date: May 2006
Location: UK - London
Posts: 330
Rep Power: 3
![]() |
Thread.AllocateNamedDataSlot
The method Thread.AllocateNamedDataSlot allocates a data slot on all threads, is there something like this but acts on the local thread instead of all the threads?
__________________
Quote:
|
|
|
|
|
|
|
#2 |
|
Newbie
Join Date: Apr 2008
Location: flagstaff az
Posts: 18
Rep Power: 0
![]() |
Re: Thread.AllocateNamedDataSlot
check this link out I believe its what your looking for http://www.dotnetcoders.com/web/Arti...icle=58&p=true
Still Uses the Thread.AllocateNamedDataSlot but then it uses a local data slot specific to the thread. Last edited by ghg5; Jun 12th, 2008 at 3:04 PM. |
|
|
|
|
|
#3 | |
|
Professional Programmer
Join Date: May 2006
Location: UK - London
Posts: 330
Rep Power: 3
![]() |
Re: Thread.AllocateNamedDataSlot
Sorry I am not that good with threads perhaps you can clear this up for me. If I have the following code:
main()
{
new Thread(doit).start(1);
new Thread(doit).start(2);
}
public void doit(object o)
{
LocalDataStoreSlot lds = Thread.GetNamedDataSlot("SleepTime");#1
Thread.setData(lds,o);#2
}Wouldn't the datastore lds points to eventually contain the value 2, or would each thread get its own slot.
__________________
Quote:
Last edited by kruptof; Jun 12th, 2008 at 3:37 PM. Reason: typo |
|
|
|
|
|
|
#4 | |
|
Expert Programmer
Join Date: Jun 2005
Posts: 852
Rep Power: 4
![]() |
Re: Thread.AllocateNamedDataSlot
From this link http://msdn.microsoft.com/en-us/libr...ddataslot.aspx
it says Quote:
|
|
|
|
|
|
|
#5 |
|
Troll
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4
![]() |
Re: Thread.AllocateNamedDataSlot
AllocateNamedDataSlot is kind of useless to you. GetNamedDataSlot will allocate it if the slot does not exist.
Each thread has its own value for a particular named data slot. They don't affect each other. Using the ThreadStaticAttribute might be easier to follow. Does essentially the same thing. http://msdn.microsoft.com/en-us/libr...attribute.aspx
__________________
MD5(sig) = bcef75433db02e9ad9bf81d6f7c5c270 |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|