dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.47k stars 4.77k forks source link

Generic host WPF-Application lifetime #36085

Open msschl opened 5 years ago

msschl commented 5 years ago

Is your feature request related to a problem?

I'm am trying out the latest .net core 3.0 preview. I want to build a wpf application that uses the generic host, so I can get some of the aspnet core magic in wpf, like e.g. DI. Is there a sample on how to get startet on this topic, especially with focus on the application lifetime management (something like UseConsoleLifetime)?

Describe the solution you'd like

A sample would be nice. Or an extension method like .UseApplicationLifetime(); on the hostbuilder.

Tratcher commented 5 years ago

@glennc

analogrelay commented 5 years ago

Related https://github.com/dotnet/wpf/issues/499

It might make sense to move this discussion to dotnet/wpf

EdinaLewis commented 4 years ago

https://github.com/dapplo/Dapplo.Microsoft.Extensions.Hosting has some good examples of implementing custom lifetime extensions for things like WPF and WinForms.

ghost commented 4 years ago

As part of the migration of components from dotnet/extensions to dotnet/runtime (https://github.com/aspnet/Announcements/issues/411) we will be bulk closing some of the older issues. If you are still interested in having this issue addressed, just comment and the issue will be automatically reactivated (even if you aren't the author). When you do that, I'll page the team to come take a look. If you've moved on or workaround the issue and no longer need this change, just ignore this and the issue will be closed in 7 days.

If you know that the issue affects a package that has moved to a different repo, please consider re-opening the issue in that repo. If you're unsure, that's OK, someone from the team can help!

analogrelay commented 4 years ago

I'm going to unstale this and move it to the runtime since we already have one for WinForms and Xamarin :). As with those, this may be something that needs to live with the WPF team, but for now we can track it.

ghost commented 4 years ago

Paging @dotnet/extensions-migration ! This issue has been revived from staleness. Please take a look and route to the appropriate repository.

Dotnet-GitSync-Bot commented 4 years ago

I couldn't figure out the best area label to add to this issue. Please help me learn by adding exactly one area label.

IanKemp commented 3 years ago

A good example at https://marcominerva.wordpress.com/2019/11/07/update-on-using-hostbuilder-dependency-injection-and-service-provider-with-net-core-3-0-wpf-applications/ (disclaimer: I am not the author, nor am I affiliated with the author in any way).