6
I have system in Asp.Net MVC (.Net 4.5) divided in layers:
That said, let’s get to the problem...
I’m trying to create a screen to send emails asynchronously (3 emails at the same time, for example), but there will be a button to cancel submissions, which forces me to inform the customer in real time, which emails have already been sent.
See the flow below:
At this point, if the user clicks the cancel button, the emails in process must be aborted and the last one does not start.
Respecting the layered architecture, I would like to address all the business rules for sending emails on the proper layer for this. But I haven’t been able to find a solution where I can send a list of objects (emails) from View Layer to the Business Layer, creating there an asynchronous process that send back to the View Layer the result of sending each email (one by one asynchronously), and which at any time allows the interruption of the whole process.
That would be the flow:
All emails are sent to the business layer:
The business layer starts an asynchronous process to send the emails, and as it completes sending each email, it responds to the display layer the result:
At any time, the customer can cancel sending, so the view layer sends a cancellation request for all tasks that are still running:
1. It is possible to send data in the opposite direction (from Business Layer for to View Layer) from a single call?
2. I must create some kind of Thread to control the sending of each email?
3. It is possible to interrupt a task that is running in a lower layer?
I do not know if I vote for the question, because it is a little vague, perhaps broad or unclear, but excellent way to present.
– Maniero
Thanks @bigown , it’s really looking a little too wide, because it’s not a specific problem as proposed here in stackoverflow. I’m having a hard time synthesizing it to fit in, maybe it was something for the community softwareengineering, but as we have nothing of the kind in Portuguese yet, I had to call for help here, rsrsrs...
– Jedaias Rodrigues
The problem is not of focus, and we do not know well what you want. Here is Sept.
– Maniero
I made an issue trying to improve a little, what do you think now?
– Jedaias Rodrigues
the best option would be to resume tasks, and first layer that made the request, pass a token cancelation to the others, until the layer that creates the sending threads, so it is possible to cancel the threads from the first layer
– Ricardo Pontual