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

Communication between threads

Jck
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!
Aug 3 '06 #1
6 9958
do you need to ghave each on different threads? the Socket class has the
ability to get data async so it wont freeze ur UI, then the socket and main
thread are on the same thread, which just makes things easier
--
-iwdu15
Aug 3 '06 #2
Jck
Do you mean I need to have a timer to check the socket receive buffer size in
UI thread?

"iwdu15" wrote:
do you need to ghave each on different threads? the Socket class has the
ability to get data async so it wont freeze ur UI, then the socket and main
thread are on the same thread, which just makes things easier
--
-iwdu15
Aug 7 '06 #3

iwdu15 wrote:
do you need to ghave each on different threads? the Socket class has the
ability to get data async so it wont freeze ur UI, then the socket and main
thread are on the same thread, which just makes things easier
That isn't really true. The async socket calls are still executed on a
separate thread from the main thread - you just don't explicitly create
that thread, it is taken from the thread pool.

--
Tom Shelton [MVP]

Aug 7 '06 #4
Jck
I still need a way for threads to communicate with each other.

Other than the Main and Socket threads, I will have some more threads such
as Printer thread and Trace log thread.

I just realize I can open a file for writing from my Main thread and let the
socket thread use the FileNumber to do any writing. However, this problem
solved if I can have the socket thread send/post a message to my Main thread.

Someone, please help!!

"Jck" wrote:
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!
Aug 7 '06 #5
Jck,

You can use any shared variable in the main and in the worker thread to use
as communication information.

Be aware that you while updating need to synclock that.

http://msdn.microsoft.com/library/de...tmSyncLock.asp

I like for that the queue class.

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

I hope this helps,

Cor

"Jck" <Jc*@discussions.microsoft.comschreef in bericht
news:D4**********************************@microsof t.com...
>I still need a way for threads to communicate with each other.

Other than the Main and Socket threads, I will have some more threads such
as Printer thread and Trace log thread.

I just realize I can open a file for writing from my Main thread and let
the
socket thread use the FileNumber to do any writing. However, this problem
solved if I can have the socket thread send/post a message to my Main
thread.

Someone, please help!!

"Jck" wrote:
>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!

Aug 7 '06 #6
Messages can be sent between threads using several mechanisms. You can
use a WaitHandle (either ManualResetEvent or AutoResetEvent) to cause a
thread to block until another thread signals an event. You can use
Monitor.Pulse and Monitor.Wait in much the same way. If one of your
threads is running a Windows message loop then you can use
Control.Invoke or Control.BeginInvoke. And of course data can be
shared between threads by making sure the variables are accessible from
the code that each thread executes. The variables themselves can even
be used a signalling mechanism. It really depends on exactly how you
want the threads to work together.

Brian

Jck wrote:
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!
Aug 7 '06 #7

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

Similar topics

17
by: Andrae Muys | last post by:
Found myself needing serialised access to a shared generator from multiple threads. Came up with the following def serialise(gen): lock = threading.Lock() while 1: lock.acquire() try: next...
9
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...
3
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...
1
by: RahimAsif | last post by:
Hi guys, I would like some advice on thread programming using C# so I wanted some advice. I am writing an application that communicates with a panel over ethernet, collects data and writes it...
6
by: RahimAsif | last post by:
Hi guys, I would like some advice on thread programming using C#. I am writing an application that communicates with a panel over ethernet, collects data and writes it to a file. The way the...
21
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...
9
by: jdlists | last post by:
I have inheirted some existing code, that i will explain in a moment, have needed to extend and ultimately should be able to run in threads. I've done a bunch of work with python but very little...
12
by: Dave | last post by:
Hi all, I have an application which has some worker threads which often have to stop and wait for some further information from other threads. These pauses will often take a long time (a couple...
0
by: nimitsis | last post by:
hello I have a problem, which in C is simple to get through of it, but in python seems not so easy to me. I have 2 python threads. Each one do a different work. The first do a computation in a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.