Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 12th, 2008, 1:41 PM   #1
kruptof
Professional Programmer
 
kruptof's Avatar
 
Join Date: May 2006
Location: UK - London
Posts: 330
Rep Power: 3 kruptof is on a distinguished road
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:
When I was young it seemed that life was so wonderful,a miracle, oh it was beautiful, magical.
Now watch what you say or they'll be calling you a radical,a liberal, oh fanatical, criminal. Oh won't you sign up your name,we'd like to feel you're acceptable, respectable, oh presentable, a vegetable
kruptof is offline   Reply With Quote
Old Jun 12th, 2008, 2:45 PM   #2
ghg5
Newbie
 
Join Date: Apr 2008
Location: flagstaff az
Posts: 18
Rep Power: 0 ghg5 is on a distinguished road
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.
ghg5 is offline   Reply With Quote
Old Jun 12th, 2008, 3:32 PM   #3
kruptof
Professional Programmer
 
kruptof's Avatar
 
Join Date: May 2006
Location: UK - London
Posts: 330
Rep Power: 3 kruptof is on a distinguished road
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:
When I was young it seemed that life was so wonderful,a miracle, oh it was beautiful, magical.
Now watch what you say or they'll be calling you a radical,a liberal, oh fanatical, criminal. Oh won't you sign up your name,we'd like to feel you're acceptable, respectable, oh presentable, a vegetable

Last edited by kruptof; Jun 12th, 2008 at 3:37 PM. Reason: typo
kruptof is offline   Reply With Quote
Old Jun 12th, 2008, 6:54 PM   #4
The Dark
Expert Programmer
 
Join Date: Jun 2005
Posts: 852
Rep Power: 4 The Dark is on a distinguished road
Re: Thread.AllocateNamedDataSlot

From this link http://msdn.microsoft.com/en-us/libr...ddataslot.aspx
it says
Quote:
Data slots are unique per thread. No other thread (not even a child thread) can get that data.
So it looks like each thread gets its own data.
The Dark is offline   Reply With Quote
Old Jun 13th, 2008, 1:53 PM   #5
Dameon
Troll
 
Dameon's Avatar
 
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4 Dameon is on a distinguished road
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
Dameon is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:41 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC