?
Solved

Sharring variables between multiple threads.

Posted on 2006-06-15
2
Medium Priority
?
296 Views
Last Modified: 2010-04-16
Hi Experts,

      I need to know the right way of sharing data between different threads.  I have a main thread which is going to spawn about 10 different instances of the same worker thread.  These worker threads are going to collect information and put them each into a seperate instance (or array member) of the same structure.  So I would like to end up with an array of the structure (myStructure[10]) whose members were populated by ten different threads simultaniously.  What's the excepted way of doing something like this?

Thanks,
axnst2
0
Comment
Question by:axnst2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 12

Accepted Solution

by:
gbzhhu earned 2000 total points
ID: 16911256
Basically, there is no magic on this other than ensuring only 1 thrwead is accessing your structure at any given 1 time.  There are a few ways of doing this using thread synchronization keywords amd classes.  The following article explains better, read all 4 pages

http://www.ondotnet.com/pub/a/dotnet/2001/08/06/csharp.html?page=1
0
 

Author Comment

by:axnst2
ID: 16911477
Thanks!  That'll be useful!
0

Featured Post

Technology Partners: 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!

Question has a verified solution.

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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

801 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