On Mar 20, 10:07 pm, Jon Skeet [C# MVP] <s...@pobox.comwrote:
salberts<albert.achtenb...@gmail.comwrote:
I am writing an application that has its UI and Logic layers. My
initial idea was to launch the two layers on two different threads and
manage calls made by the UI to the Logic manually.
Why? I don't see any benefit in introducing threading here.
A friend of mine advised me to avoid the thread handling and use the
Invoke mechanism instead.
Well, you certainly need to use extra threads for long-running
operations (assuming it's a WinForms app) but that doesn't actually
"avoid" thread handling.
The Logic layer basically has serial flow and does not require multi
threading except when interacting with the UI.
In that case don't introduce threading artificially. Life is hard
enough without adding complexity for no benefit :)
--
Jon Skeet - <s...@pobox.com>http://www.pobox.com/~skeet Blog:http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Hi,
First of all thanks for all the quick replies. I think I understand
the direction all who replied is heading to. I just want to clarify
what my program does.
The "Logic" is a process (not the operation system term) that does
some computational work. Its interaction with the UI is done to
accomplish three main tasks:
1. Send output to the user.
2. Ask for input from the user. And later on recieve the input
response.
3. Receive command from user (such as back, finish, terminate, etc)
So it is a continuous work flow and not a bunch of separated
computational actions such as DoTransaction(). In addition since the
input request/response is done asynchronously in any case, I have to
synchronize this scenario. So I think that adding a small thread
control mechanism here (in some kind of a mediator classof course)
would be quite easy and will make the work flow more intuitive and
easier to understand and debug.
Albert