Re: Multithreading

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Ioannis Vranos (ivr_at_remove.this.grad.com)
Date: 02/23/05


Date: Wed, 23 Feb 2005 13:33:45 +0200

Alper AKCAYOZ wrote:

> 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

-- 
Ioannis Vranos


Relevant Pages

  • Re: thread autorelease pools help requested
    ... there's a link to the Multithreading Programming Topics guide. ... nothing explains what precisely lock does. ...
    (comp.sys.mac.programmer.help)
  • Re: fast drawing in delphi
    ... I use a Delphi multithreading component. ... I found a Lock procedure that applies to GraphicalObject in the Help ... Blocks other execution threads from using the associated canvas until the ... Call Lock in a multithreaded application before using the graphics object in ...
    (comp.lang.pascal.delphi.misc)
  • Rendezvous based mutithreading.
    ... > Martin Krischik wrote: ... > The only multithreading I know is the .NET lock-based multithreading. ... multithreading - I was only used to lock based multithreading from C ... Ada programming at: http://ada.krischik.com ...
    (comp.lang.cpp)
  • Rendezvous based mutithreading.
    ... > Martin Krischik wrote: ... > The only multithreading I know is the .NET lock-based multithreading. ... multithreading - I was only used to lock based multithreading from C ... Ada programming at: http://ada.krischik.com ...
    (comp.lang.ada)