473,804 Members | 3,725 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Communication between threads

Hi all

i got an asignment where is should simulate 1000 clients connecting to
a server via TCP, and each client has it's own sequence of data
exchanged so i have to have 1000 threads, so my bigest problem is how
can these threads communicate with each other something like this
Thread1 registers in the mailing system
Thread1 constantly monitores his mailbox
Thread2 registers in the mailing system
and he also checks his mailbox
then he sends a message HELLO to Thread1 which is in the mail
office recognized as RECIPIENT: thread1

Thread1 takes out his message and posts this back....

And this messages can be processed between all 1000 threads so it must
be fast

is there any mechanism in C# something like
Register thread1 as thread1

then thread2 says POSTMESSAGE (thread1, object message)

and thread 1 check message as PeekMessage(thr ead1, object
returnmessage)

Hope someone can help

Thank you!

Feb 8 '06 #1
1 2594
<al*********@gm ail.com> wrote:
i got an asignment where is should simulate 1000 clients connecting to
a server via TCP, and each client has it's own sequence of data
exchanged so i have to have 1000 threads, so my bigest problem is how
can these threads communicate with each other something like this
Thread1 registers in the mailing system
Thread1 constantly monitores his mailbox
Thread2 registers in the mailing system
and he also checks his mailbox
then he sends a message HELLO to Thread1 which is in the mail
office recognized as RECIPIENT: thread1

Thread1 takes out his message and posts this back....

And this messages can be processed between all 1000 threads so it must
be fast

is there any mechanism in C# something like
Register thread1 as thread1

then thread2 says POSTMESSAGE (thread1, object message)

and thread 1 check message as PeekMessage(thr ead1, object
returnmessage)


Just use a Queue (or similar) that both threads have access to,
remembering to lock appropriately to avoid data races, volatility
problems etc.

If you want to wait until a message arrives, you can use a classic
producer/consumer pattern. See half way down
http://www.pobox.com/~skeet/csharp/t...eadlocks.shtml

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Feb 8 '06 #2

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

Similar topics

1
1654
by: Ayende Rahien | last post by:
Is it possible to use events as a communication mechanism between threads?
1
4885
by: Noel | last post by:
Hi, I am a tad confused about if there are any benefits from using asynchronous vs synchronous network communication. As my example, I have been writing a dns lookup stack with a network communication class switchable between asynchronous and synchronous. When I use asynchronous udp communication I find that if I want to process a large amount of dns lookups I have one dns provider with many state objects passing through (and a high...
9
2738
by: Emmanuel Charruau | last post by:
Hi, I am looking for a class or any information which would allow me to make communicate mini-module in c++. I have been looking on the net for some examples of such implementation, but I did not find any good one. This is why I am asking here if some of you know where to find some information on the internet about such implementation.
3
1964
by: Bryan Christopher | last post by:
Hello All! I have a rather abstract question for some genius out there to answer. I want to integrate communication tracking, for customer relations, into an existing Access DB. What I was going for is this... tblCommunications trxCommunicationThreads ----------------- ----------------------- CommunicationID (PK) CommID1 (FK1)(PK) ContactID (FK from contact table) CommID2...
2
1520
by: WTH | last post by:
with a C# client (and/or server, but server not important)? I've got a scalable high speed (uses completion ports) C++ TCP/IP communication server but I'd like to write a C# client that other C# devs at our company can just drop in and use (it's an event and message passing system.) I'm sure, as most things C#/.Net, it's relatively simple, but if I can discover some caveats the easy way rather than the hard way I'm always up for that...
21
1947
by: dast | last post by:
Hi, I'm having trouble letting my background thread tell my main thread what to do. I'm trying to tell my main thread to open a form, but when my background thread ends, the form that I thought my main thread had opened disappears. Obviously there's something that I don't understand here. The background thread is run in another class on another form. How do I,
8
5697
by: Roodie | last post by:
Hello, I have a quite specific problem, and after half a day spent with Google, still no solid answer. The task: I have to write a C# class Library ( DLL ) to handle TCP socket communication. It will be called by a multithreaded server application to send some data to an another server ( which is a linux server ).
2
2468
by: ne.seri | last post by:
In short, I'm building a kind of server which is supposed to handle open connections with clients. E.g. client connects to the server, the connection stays open, client sends a request to the server, server reasoned, and so on... The thing is that connection MUST always stay open. I'm using C++, and as for sockets, I'm using native syscalls, not MFC. I'm using stream sockets for communication. Another thing is that is should work both...
6
9994
by: Jck | last post by:
Could someone tell me how a thread can send data / post message to another thread in vb.net please? I have a main thread and a socket thread. I need a way to let the main thread know when my socket thread receive data. Thanks in advance!
1
5261
by: batista | last post by:
Hello all, I need suggestions and possibly solutions to the problem stated below: I have an application written purely in .NET ( Windows Form Application) and another application that is supposed to be written in MFC(Visual C++) or Win32 GUI Application. The problem is to communicate data between the two applications. for example,
0
9579
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10076
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7616
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6851
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5520
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4297
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3816
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2990
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.