Windows Forms advice

A

abhiM

Hi,
This is a very general question. I am about to embark on
developing a new application (Windows Forms based). All the business
logic, external interfaces etc have already been developed and are
available as ready to use libraries.
This application is going to be multi-threaded. Is it recommended
to have each of the different forms or at least a couple of related
forms packaged into separate libraries. Is such a packaging going to
have any effect on the multi-threaded nature of the application. This
is the first time I am using threading and I need to use threads to
display the status of some of the devices in the system in real time.
Any recommendations and any advice is greatly appreciated.

Thanks,
AM
 
K

Kevin Spencer

A Windows Forms application runs in a Single-Threaded Apartment model, with
a single thread handling the execution of the UI. Any threading you do will
have to be done by non-UI classes. Putting various forms into different
assemblies has no effect on the application, though.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

I had the same problem once. Fixed it using the same solution.
 
S

Stoitcho Goutsev \(100\)

abhiM,

Physical deploinment of your application has nothing to do with the
multithreading. Yes you can have different controls/classes from different
assemblies together in a multithread application. At the very end they all
get laoded into the memory allocated to the same process. However Windows
Forms UI is very much thread sensitive - you cannot modify the UI from a
thread different than the UI thread created the control. In order to do that
you need to marshal UI related calls from worker threads to the main UI
thread. This is mesically done via Control.InvokeRequired,Control.Invoke
and/or Control.BeginInvoke members. How to properly update the UI in a
multithread application has been discussed a lot in the newsgroups, forums
and blogs. I believe you can find easely good information and guidelines on
the web.
 

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

Top