473,395 Members | 1,999 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,395 software developers and data experts.

Problem with keeping track of threads.

I'm writing some software that opens multiple instances of a single class in
new threads. I need a way of keeping track of all these class instances in
some kind of collection. I'm basicaly writing an MSN Messenger like
application. The threads being, in this case, the chat windows. I would like
to be able to access the various referances in a similar way to the
following if it can be done...
convoThreads["oj******@hotmail.com"].someFunctionInTheClass();

Has anyone got anyideas how I can do this?

Thanx Josh
Nov 16 '05 #1
1 1895
So long as convoThreads is a singleton accessed in a thread-safe manner,
this should be fine. For the collection class you are using, see it's
discussion of thread safety (hint: lock(theCollection) is insufficient for
thread safe usage of a collection).

Brad Williams
"Joshua Russell" <joshATojmyster|DOTukDOTTeuDOOTorgNOSPAM.PLZ> wrote in
message news:OJ**************@tk2msftngp13.phx.gbl...
I'm writing some software that opens multiple instances of a single class in new threads. I need a way of keeping track of all these class instances in
some kind of collection. I'm basicaly writing an MSN Messenger like
application. The threads being, in this case, the chat windows. I would like to be able to access the various referances in a similar way to the
following if it can be done...
convoThreads["oj******@hotmail.com"].someFunctionInTheClass();

Has anyone got anyideas how I can do this?

Thanx Josh

Nov 16 '05 #2

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

Similar topics

5
by: Ralph Sluiters | last post by:
Hi, i've got a small problem with my python-script. It is a cgi-script, which is called regulary (e.g. every 5 minutes) and returns a xml-data-structure. This script calls a very slow function,...
15
by: Eric J. Holtman | last post by:
I feel like the answer to this should be blinding obvious. I also feel like it's probably an exercise in an undergraduate database design course. I'm off to google for an answer, but I figure I'd...
9
by: Alfred Taylor | last post by:
I'm testing the waters of n-tier development and I ran into a scenario that I'm not sure what the best solution would be. I have a Company object which contains a collection of contacts retrieved...
2
by: xzzy | last post by:
I need to create threads and monitor their status via Name = RowID. I thought a hashtable of threads would do it, but I cannot get it to work. Does anyone know of an article or code snippet I...
3
by: Dave | last post by:
Hi, I have a .NET class which uses the .NET threadpool (using QueueUserWorkItem) to create about 8 threads, which do some work while the parent thread waits for them all to complete, which works...
2
by: metaperl | last post by:
I'm actually taking Microsoft's 2779 and just finished a lab where we kept track of our changes to the database. However, I'm not happy with the scripts interface because it does not tell me the...
14
by: =?Utf-8?B?UHVjY2E=?= | last post by:
Hi, I'm using VS2005 and .net 2.0. I'm creating an application that has 3 forms. I want allow users to move forward and backward with the forms and retain the data users have entered. I thought...
7
by: souravmallik | last post by:
Hello, I'm facing a big logical problem while writing a parser in VC++ using C. I have to parse a file in a chunk of bytes in a round robin fashion. Means, when I select a file, the parser...
2
by: Gabriel Genellina | last post by:
En Tue, 13 May 2008 06:42:13 -0300, Astan Chee <stanc@al.com.auescribió: I'm confused trying to understand your requirements too. "run a class?" Threads execute code, it's easier to think of...
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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.