Multithreading

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,
I am developing a TCP/IP Client application in Windows Forms (.NET)
template. I use one MDI form as initial form where I connect to server and
starts a background thread (thread_A) for receiving data. Here, I use the
Socket_A

By clicking a toolbarbutton, I send a command to server. If it is
successfull, I opened the MDI-Child form with "frmChildForm->Show();" command.
I create two more sockets (Socket_B, Socket_C) at child form and start
receiving continuously (in while-loops) with two threads (Thread_B,
Thread_C). I display the data coming from these sockets on 25 textboxes
(Thread_B with Socket_B) and on 3 data-grids (Thread_C with Socket_C). These
operations must be as fast as possible. Thread_B and Thread_C are not sharing
any data, they are independent.

I could not speed up the data-receving which means I could not order Threads.
I read several documents at MSDN like ThreadPool, Monitor. But I could not
solve my problem. I put several "Thread::Sleep(...);" in Thread_B and
Thread_C, but it is not still working properly. Data on textboxes and
datagrids are not changing fast, sometimes some values are stucking.

I am requesting a way to make use of Threads more efficiently.?

I thank you so much in advance.

--
İyi Çalışmalar
Alper AKÇAYÖZ (Bil Muh)

Wish You Good Work
Alper AKCAYOZ (Bil Muh)
 
Alper said:
Hello,
I am developing a TCP/IP Client application in Windows Forms (.NET)
template. I use one MDI form as initial form where I connect to server and
starts a background thread (thread_A) for receiving data. Here, I use the
Socket_A

By clicking a toolbarbutton, I send a command to server. If it is
successfull, I opened the MDI-Child form with "frmChildForm->Show();" command.
I create two more sockets (Socket_B, Socket_C) at child form and start
receiving continuously (in while-loops) with two threads (Thread_B,
Thread_C). I display the data coming from these sockets on 25 textboxes
(Thread_B with Socket_B) and on 3 data-grids (Thread_C with Socket_C). These
operations must be as fast as possible. Thread_B and Thread_C are not sharing
any data, they are independent.

I could not speed up the data-receving which means I could not order Threads.
I read several documents at MSDN like ThreadPool, Monitor. But I could not
solve my problem. I put several "Thread::Sleep(...);" in Thread_B and
Thread_C, but it is not still working properly. Data on textboxes and
datagrids are not changing fast, sometimes some values are stucking.

I am requesting a way to make use of Threads more efficiently.?

I thank you so much in advance.


I know .NET multithreading. In .NET, for thread synchronization you need
to use lock-based multithreading, by getting and release the thread
lock. This is done by using some .NET facilities which include
Monitor::Enter() to acquire the lock, Monitor::Exit() to release the
lock, however the lock is released implicitly in a Monitor::Wait() call.


A nice beginner to intermediate level book that you can read, and covers
all .NET facilities, and covers multithreading as also networking among
them, is "Visual C++ .NET How To Program" by Deitel.

http://vig.prenhall.com/catalog/academic/product/0,1144,0134373774,00.html
 
Two points:

1. I'd rather used remoting or web services to communicate with a server,
then custom socket protocol.
2. UI need not be faster then human beings. This means that there is no
point to update view too fast.
 
Back
Top