Click here to Skip to main content
15,887,683 members
Home / Discussions / Design and Architecture
   

Design and Architecture

 
Questionn-Tier Architecture and Async Pin
Kevin Marois10-May-19 6:07
professionalKevin Marois10-May-19 6:07 
AnswerRe: n-Tier Architecture and Async Pin
Richard Deeming10-May-19 6:46
mveRichard Deeming10-May-19 6:46 
GeneralRe: n-Tier Architecture and Async Pin
Kevin Marois10-May-19 7:18
professionalKevin Marois10-May-19 7:18 
GeneralRe: n-Tier Architecture and Async Pin
Richard Deeming10-May-19 9:02
mveRichard Deeming10-May-19 9:02 
GeneralRe: n-Tier Architecture and Async Pin
Kevin Marois10-May-19 9:10
professionalKevin Marois10-May-19 9:10 
GeneralRe: n-Tier Architecture and Async Pin
Richard Deeming10-May-19 9:50
mveRichard Deeming10-May-19 9:50 
GeneralRe: n-Tier Architecture and Async Pin
Kevin Marois10-May-19 10:08
professionalKevin Marois10-May-19 10:08 
GeneralRe: n-Tier Architecture and Async Pin
Richard Deeming10-May-19 11:05
mveRichard Deeming10-May-19 11:05 
Using Task.Run is fine in a desktop application if you want to push CPU-bound work onto a background thread, so that your UI doesn't freeze.

In server-side code, it doesn't make a lot of sense to use async for CPU-bound work. There is no UI, so a background thread will just make more work for the server.

Have a look at the link from Alberto's answer:
However, avoid "fake asynchrony" in libraries. Fake asynchrony is when a component has an async-ready API, but it’s implemented by just wrapping the synchronous API within a thread pool thread. That is counterproductive to scalability on ASP.NET.

For server-side code, async is best suited for IO-bound code. In other words, when your code is waiting for some external resource - eg: a file-system call, a network request, a database query. In that case, the async code will most likely use an IO completion port[^] to resume the method when the request has completed, and no threads will be tied up waiting for a response.

Actually writing a low-level async method which isn't just composed of calling other async methods is usually not a trivial task. Probably one of the simplest examples would be Task.Delay[^], which uses a Timer to trigger the completion of a task. Stephen Toub also wrote a whole series of posts about building async coordination primitives[^] using the TaskCompletionSource class.



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer

GeneralRe: n-Tier Architecture and Async Pin
Nathan Minier10-May-19 7:32
professionalNathan Minier10-May-19 7:32 
GeneralRe: n-Tier Architecture and Async Pin
Kevin Marois10-May-19 7:36
professionalKevin Marois10-May-19 7:36 
QuestionLookup Editor Design Question Pin
Kevin Marois27-Apr-19 7:28
professionalKevin Marois27-Apr-19 7:28 
AnswerRe: Lookup Editor Design Question Pin
Mycroft Holmes27-Apr-19 13:29
professionalMycroft Holmes27-Apr-19 13:29 
GeneralRe: Lookup Editor Design Question Pin
Kevin Marois27-Apr-19 13:44
professionalKevin Marois27-Apr-19 13:44 
GeneralRe: Lookup Editor Design Question Pin
Mycroft Holmes27-Apr-19 13:49
professionalMycroft Holmes27-Apr-19 13:49 
GeneralRe: Lookup Editor Design Question Pin
Kevin Marois27-Apr-19 13:57
professionalKevin Marois27-Apr-19 13:57 
GeneralRe: Lookup Editor Design Question Pin
Eddy Vluggen28-Apr-19 1:09
professionalEddy Vluggen28-Apr-19 1:09 
QuestionJ2EE or the other stuff. Pin
abmv22-Apr-19 7:35
professionalabmv22-Apr-19 7:35 
AnswerRe: J2EE or the other stuff. Pin
Eddy Vluggen22-Apr-19 8:00
professionalEddy Vluggen22-Apr-19 8:00 
AnswerRe: J2EE or the other stuff. Pin
Gerry Schmitz22-Apr-19 8:30
mveGerry Schmitz22-Apr-19 8:30 
AnswerRe: J2EE or the other stuff. Pin
jschell27-Apr-19 7:54
jschell27-Apr-19 7:54 
QuestionDropBox Style App Pin
Kevin Marois17-Apr-19 11:07
professionalKevin Marois17-Apr-19 11:07 
AnswerRe: DropBox Style App Pin
abmv22-Apr-19 7:43
professionalabmv22-Apr-19 7:43 
AnswerRe: DropBox Style App Pin
Eddy Vluggen22-Apr-19 7:58
professionalEddy Vluggen22-Apr-19 7:58 
AnswerRe: DropBox Style App Pin
Gerry Schmitz22-Apr-19 8:36
mveGerry Schmitz22-Apr-19 8:36 
GeneralRe: DropBox Style App Pin
Kevin Marois22-Apr-19 9:08
professionalKevin Marois22-Apr-19 9:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.