This extension method does everything else shown in the diagram. The name is pretty descriptive; this method configures itself so that it will pause until the ApplicationStopping cancellation token on IHostApplicationLifetime is triggered we'll look at how that token gets triggered shortly. The extension method achieves this using a TaskCompletionSource , and await -ing the associated Task. This isn't a pattern I've needed to use before and it looked interesting, so I've added it below adapted from HostingAbstractionsHostExtensions.
This extension method explains how the application is able to "pause" in a running state, with everything running in background tasks. Lets look in more depth at the IHost. StartAsync method call at the top of the previous diagram. In the previous diagram we were looking at the HostingAbstractionsHostExtensions extension methods which operate on the interface IHost.
If we want to know what typically happens when we call IHost. StartAsync then we need to look at a concrete implementation. The diagram below shows the StartAsync method for the generic Host implementation that is used in practice. Again, we'll walk through the interesting parts below. As you can see from the diagram above, there's a lot more moving parts here! The call to Host. NET Core apps.
The SystemdLifetime behaves very similarly to the ConsoleLifetime , with a couple of extra features. The WindowsServiceLifetime is quite different , and derives from System. The ConsoleLifetime. It is these events that are fired when application shutdown is requested.
So it's the IHostLifetime that is typically responsible for controlling when the application shuts down. As shown in the code above, this method completes immediately and returns control to Host. This includes the GenericWebHostService that starts the Kestrel web server which is started last , hence my previous post on async startup tasks.
Once all the IHostedService s have been started, Host. NotifyStarted to trigger any registered callbacks typically just logging and exits. The former contains the logic for controlling when the application starts. The latter implemented by ApplicationLifetime contains CancellationTokens against which you can register callbacks to run at various points in the application lifecycle.
At this point the application is in a "running" state, with all background services running, Kestrel handling requests, and the original WaitForShutdownAsync extension method waiting for the ApplicationStopping event to fire. The diagram below shows the interaction between all the key players in the shutdown process:. StopApplication method. This triggers all the callbacks that were registered with the ApplicationStopping cancellation token.
If you refer back to the program overview , you'll see that trigger is what the original RunAsync extension method was waiting for, so the await ed task completes, and Host.
StopAsync is invoked. StopApplication again. This second call is a noop when run for a second time, but is necessary because technically there are other ways Host. StopAsync could be triggered. Next, Host shuts down all the IHostedService s in reverse order. Services that started first will be stopped last, so the GenericWebHostedService is shut down first. After shutting down the services, IHostLifetime. Finally, Host.
- Teach Yourself VISUALLY Computers (Teach Yourself VISUALLY (Tech)).
- NEW RELEASES?
- Popular Tags.
NotifyStopped to run any associated handlers again, mostly logging before exiting. Search Pre-Algebra All courses.
Pre-Algebra Explore and understand integers Overview Absolute value Adding and subtracting integers Multiplying and dividing with integers. Pre-Algebra Inequalities and one-step equations Overview Different ways to solve equations Calculating the area and the perimeter Solving inequalities Understanding inequalities and equations. Pre-Algebra Discover fractions and factors Overview Monomials and adding or subtracting polynomials Powers and exponents Multiplying polynomials and binomials Factorization and prime numbers Finding the greatest common factor Finding the least common multiple.
Pre-Algebra More about the four rules of arithmetic Overview Integers and rational numbers Learn how to estimate calculations Calculating with decimals and fractions Geometric sequences of numbers Scientific notation. Are you good at study?
- The Physical Principles of the Quantum Theory (Dover Books on Physics).
- Motivation and Narrative in Herodotus (Oxford Classical Monographs).
- Main navigation!
- A Fork in the Road?
- Fallen Bodies: Pollution, Sexuality, and Demonology in the Middle Ages (The Middle Ages Series).
Have you ever taken a position in your class? What kind of films do you like to watch? What 's your favourite programme?
Introducing Roblox Premium
What's your name? Where are you from? How are you?
What do you do? What food do you like to eat? Do you like pets? What is your hobby? Do you have nick name? Are you at the university? Where donyou study? Do you have work? Which your position? I think not correct because it has no verb? We can write that Which is your position?
Me:hi,what's your name? Me:Are you really Prince? Me:ok,How old are you?
Introducing the 12222 UX Designers to Watch
Prince:I'm And you? Me:I'm Prince: I'm a student. What class are you in? Prince : I am in class 8. Me: me too. Me: Have you ever taken position in your class? Prince : yes , sometimes. Me : wow Are you Vietnamese?
Introducing Books – Graphic Guides
I started my studying in English just a few time ago. When I begin a conversation, I often ask: where the person is from, how old the person have or what is the hobbies. Where're you from? What do you like the best?