inter process communication versus threads

M

mastermagrath

Hi all,

I recently finished a small project using perl and tk/tcl which caused
me several headaches. I have now decided to have a go at VB .net and
thought a good place to start would be recreating the perl
application.
However, once again i'm running into similar headaches and wondered if
i could get a real developers opinion on how he/she would implement
it.
Basically the application is a small GUI wherein the user can enter an
IP address/port number.
There are two slider (track bars) controls which represent packet rate
per second and packet size in bytes.
When the start button is clicked a udp socket is created and the
application then starts to write packets to the socket according to
the values in the sliders. The user can change the slider values such
that they can change the udp packet rate and/or packet size in real
time.
In the perl implementation i did this via threads where a separate
thread ran the udp socket.
The sliders in the main thread would update global variables which
were declared as shared. This allowed the udp thread to access them so
when a change occured in the slider values, the thread would take the
new values on board and adjust the action of writing to the udp socket
accordingly.

However, it seems that to do this in vb .net the advice i keep reading
is that windows form controls are not thread safe, and i can't really
get a good notion of how to do this. As understand it you can give a
thread an initial value and read a result once its finished but here i
need to be able to send it values as soon as the user changes it.

When writing in perl i also looked into creating separate processes
and communicating between them via sockets etc as i was having similar
problems with threads and tk/tcl. However i managed to get around them
and it seems to work quite well.

Anyway, i'm not a developer and so i would love to hear from anyone
who is how they would go about doing this i.e. threads, separate
processes or something else i'm not aware of.

I'd really appreciate it.

Thanks!
 
R

Robin Tucker

Hi Master,

You are right, they are not thread safe. This is why Microsoft gave the
Control object an "Invoke" method. Invoke will ensure the method on the
control is called on the controls thread, not on the callers thread. To
learn more, google for Control.Invoke+VB.NET or look in MSDN. Also look
for BeginInvoke, EndInvoke for asynchronous invocation.




Robin
 
M

mastermagrath

Hi Master,

You are right, they are not thread safe. This is why Microsoft gave the
Control object an "Invoke" method. Invoke will ensure the method on the
control is called on the controls thread, not on the callers thread. To
learn more, google for Control.Invoke+VB.NET or look in MSDN. Also look
for BeginInvoke, EndInvoke for asynchronous invocation.

Robin

Thanks Robin, i'll take you up on your advice.

Thanks for replying.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Threads question 3
the Socket Class 1
Communication between threads 6
Can't send a udp packet to the local PC? 1
Bounding the same UDPClient to two threads 5
threads 1
fast reliable IPC 7
Watched threads ??? 3

Top