c# - ActionNameAsync-ActionNameCompleted vs async-await in Asp.NET MVC -
i'm starting async mvc , know wich main difference between 2 implementations of asynccontroller.
the first 1 using viewnameasync , viewnamecompleted implementation:
public class homecontroller : asynccontroller { // ... manager declaration ... public void indexasync() { asyncmanager.outstandingoperations.increment(); manager.expensiveoperationcompleted += () => { debug.writeline("expensive operation completed."); asyncmanager.outstandingoperations.decrement(); }; manager.expensiveoperationasync(); } public actionresult indexcompleted() { return view(); } } and second 1 using async-await implementation:
public class homecontroller : controller { // ... manager declaration ... public async task<actionresult> index() { await manager.expensiveoperation(); return view(); } }
the "main difference" async/completed approach using outdated , less maintainable way asynchronous request handling.
Comments
Post a Comment