The method allows for a Task instance to configure its awaiter. In einem Restaurant, in dem mehrere Bestellungen aufgegeben werden, könnte der Koch mit der Zubereitung eines weiteren Frühstücks beginnen, während das erste Frühstück zubereitet wird.In a restaurant where multiple orders are placed, the cook could start another breakfast while the first is cooking. The preceding code showed you that you can use. In fact, you can forgo Task.WhenAll even here if you await both tasks instead of calling Result directly: Long and short, it's really just a matter of taste more than anything.
Ohne Sprachunterstützung erforderte das Schreiben von asynchronem Code Rückrufe, Abschlussereignisse oder andere Methoden, die die ursprüngliche Absicht des Codes verdeckten.Without language support, writing asynchronous code required callbacks, completion events, or other means that obscured the original intent of the code. They are simply marker classes for the purpose of demonstration, contain no properties, and serve no other purpose. So, we'll add the aspectjrt Maven dependency: Next, we'll add the jcabi-maven-plugin plugin that weaves the binaries with AspectJ aspects. You compose tasks by separating the operations into a new method that returns a task. Say you're writing a mobile game where pressing a button can inflict damage on many enemies on the screen. There's also an argument to be made that if you have that much logic, your method might be doing too much in the first place.
Um beim Beispiel des Frühstücks zu bleiben, würden Sie dieses sehr viel schneller zubereiten können.In the breakfast analogy, that's how you get breakfast done more quickly.
Aufgaben sollen nicht sequenziell ausgeführt werden.You don't want each of the component tasks to be executed sequentially.
Das liegt daran, dass einige Aufgaben gleichzeitig ausgeführt werden konnten und der Code mehrere Aufgaben gleichzeitig überwachen und nur bei Bedarf eingreifen konnte.The final version of the asynchronously prepared breakfast took roughly 15 minutes, this is because some tasks were able to run concurrently, and the code was able to monitor multiple tasks at once and only take action when it was needed. THE unique Spring Security education if you’re working with Java today. The advantage of the synchronous code is that it's step-by-step actions make it easy to scan and understand. Computer interpretieren diese Anweisungen anders als Menschen. Stated another way, if any portion of an operation is asynchronous, the entire operation is asynchronous. Der obige Code zeigt eine schlechte Praxis: das Erstellen von synchronem Code zum Ausführen asynchroner Vorgänge.The preceding code demonstrates a bad practice: constructing synchronous code to perform asynchronous operations. Cheers.