Two-way asynchronous communication in layers

5

I have system in Asp.Net MVC (.Net 4.5) divided into layers:

Thatsaid,let'sgetdowntotheproblem...

I'mtryingtocreateascreentosendemailsasynchronously(3emailsatthesametime,forexample),buttherewillbeabuttontocancelthesending,whichforcesmetoinformthecustomerinrealtime,whichemailshavealreadybeensent.

Seethestreambelow:

Atthistime,iftheuserclicksthecancelbutton,in-processemailsshouldbeabortedandthelastonedoesnotevenbegin.

Respectingthelayeredarchitecture,Iwouldliketodealwithallthebusinessrulesforsendingtheemailsinthelayeritselfforthis.ButIhavenotyetbeenabletofindasolutionwhereIcansendalistofViewLayerobjectstotheBusinessLayer,creatinganasynchronousprocesstherethatsendsitbacktotoViewLayertheresultofsendingeachemail(onebyoneasynchronously),andatanytimemakesitpossibletointerrupttheentireprocess.

Thatwouldbetheflow:

Allemailsaresenttothebusinesstier:

Thebusinesslayerstartsanasynchronousprocesstosendtheemails,andasitcompletesthesendingofeachemail,itrespondstothepreviewlayertheresult:

Atanytime,theclientcancancelthesubmission,sothepreviewlayersendsacancellationrequestforallthetasksthatarestillrunning:

  

1. You can send data in the opposite direction (from Business Layer ) to   to View Layer ) from a single call?

     

2.

     

3. Is it possible to interrupt a task that is running on a lower layer?

    
asked by anonymous 30.06.2017 / 15:25

1 answer

0

I would like ViewLayer working with javascript (AJAX) calling async to your BLL (businessLayer) so it would be very easy to stop the execution of the process.

Behavior of $ Ajax is already async by nature. So I could call an $ Ajax = > Start and then a Stop. Inside Ajax. I would be receiving the data and displaying it to the client.

    
22.08.2017 / 16:31