473,405 Members | 2,373 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,405 software developers and data experts.

single class, hashtable, multiple threads

Hello All,

I have a single class windows service that includes a function that
runs in the ThreadPool. The class contains a hashtable which is
declared in the main thread.

What is the recommended method of updating a variable declared in the
main thread from a spawned threadpool thread ?
Thanks in advance

Feb 12 '07 #1
2 1555
You can use Hashtable.Synchronized:

http://msdn2.microsoft.com/en-us/lib...chronized.aspx

Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"hharry" wrote:
Hello All,

I have a single class windows service that includes a function that
runs in the ThreadPool. The class contains a hashtable which is
declared in the main thread.

What is the recommended method of updating a variable declared in the
main thread from a spawned threadpool thread ?
Thanks in advance

Feb 12 '07 #2
Be aware also that Hashtable.Synchronized is not really RW safe.
It does synchronize writers, but not readers.

"Peter Bromberg [C# MVP]" <pb*******@yahoo.yabbadabbadoo.comha scritto nel
messaggio news:09**********************************@microsof t.com...
You can use Hashtable.Synchronized:

http://msdn2.microsoft.com/en-us/lib...chronized.aspx

Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"hharry" wrote:
>Hello All,

I have a single class windows service that includes a function that
runs in the ThreadPool. The class contains a hashtable which is
declared in the main thread.

What is the recommended method of updating a variable declared in the
main thread from a spawned threadpool thread ?
Thanks in advance


Feb 13 '07 #3

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

Similar topics

6
by: M Ali | last post by:
Hi, We have a c++ application that accesses many different modules. Each of these modules is responsible for it's own serialization. We have seperate olestorages for each of the module. The...
5
by: Cyrus | last post by:
I have a question regarding synchronization across multiple threads for a Hashtable. Currently I have a Threadpool that is creating worker threads based on requests to read/write to a hashtable....
33
by: Ken | last post by:
I have a C# Program where multiple threads will operate on a same Hashtable. This Hashtable is synchronized by using Hashtable.Synchronized(myHashtable) method, so no further Lock statements are...
2
by: Paul Wu | last post by:
From what I understand, in ASP.NET, each HTTP requests is serviced by a separate thread. So if my code uses a static Class with shared members and properties, I can manage concurrent access by using...
6
by: cj | last post by:
I want to make a class that will write data to a in memory table. This class will be called by multiple threads. I'm hoping the table can stay in memory between calls and all the call by the...
10
by: chrisben | last post by:
Hi, Here is the scenario. I have a list of IDs and there are multiple threads trying to add/remove/read from this list. I can do in C# 1. create Hashtable hList = Hashtable.Synchronized(new...
2
by: PAzevedo | last post by:
I have this Hashtable of Hashtables, and I'm accessing this object from multiple threads, now the Hashtable object is thread safe for reading, but not for writing, so I lock the object every time I...
35
by: keerthyragavendran | last post by:
hi i'm downloading a single file using multiple threads... how can i specify a particular range of bytes alone from a single large file... for example say if i need only bytes ranging from...
4
by: Mark S. | last post by:
Much to my surprised the code below compiled and ran. I just don't know enough about threading to know for sure if this is too good to be true. I'm attempting to isolate the Hashtable lock to...
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: 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?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.