Background operations in controller/presenter or form?

I have a desktop application with each window decopuled into presentation layer (containing the Form/Controls etc.) and application layer (Controller/Presenter – naming is irrelevant to the question). Presentation layer is passive, it only displays the data provided by application layer and comunicates with it using events. Application layer does all the plumbing connecting events to methods which populate the presentation layer with data from DB.

I use threads or BackgroundWorker to do time-consuming loading in background. My question is: which layer should be aware of the background operation implemenation and start the background threadS?

If i put the BackgroundWorker in the presentation layer, than controller’s implementation is greatly simplified – it doesn’t care if particular event was fired in background or not. However this complicates the code of the Form, which already tends to be bloated with it’s controls event handling methods (click etc.).

I would like to know where and why the background-thread aware code should be.


Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *