Dreamine.Hybrid.Wpf 1.0.3
`AddDreamineHybridWpf()` 내부에서 `AddWpfBlazorWebView()` 호출 및
로딩중...
검색중...
일치하는것 없음
DreamineWpfHostExtensions.cs
이 파일의 문서화 페이지로 가기
2using Microsoft.Extensions.Hosting;
3using System;
4using System.Windows;
5using System.Windows.Interop;
6using System.Windows.Media;
7
9{
18 public static class DreamineWpfHostExtensions
19 {
28 private const string SoftwareRenderingEnvironmentVariable = "DREAMINE_WPF_SOFTWARE_RENDERING";
29
62 public static void RunDreamineWpfApp<TApplication>(this IHost host)
63 where TApplication : Application, new()
64 {
65 if (host is null)
66 {
67 throw new ArgumentNullException(nameof(host));
68 }
69
71 host.StartAsync().GetAwaiter().GetResult();
72
73 TApplication app = new();
74
75 if (app is IDreamineServiceProviderAware hostAwareApplication)
76 {
77 hostAwareApplication.SetServiceProvider(host.Services);
78 }
79
80 try
81 {
82 app.Run();
83 }
84 finally
85 {
86 try
87 {
88 using var cts = new System.Threading.CancellationTokenSource(TimeSpan.FromSeconds(10));
89 host.StopAsync(cts.Token).GetAwaiter().GetResult();
90 }
91 finally
92 {
93 host.Dispose();
94 }
95 }
96 }
97
106 private static void ConfigureWpfRendering()
107 {
108 var softwareRendering = Environment.GetEnvironmentVariable(SoftwareRenderingEnvironmentVariable);
109 if (!string.Equals(softwareRendering, "1", StringComparison.OrdinalIgnoreCase) &&
110 !string.Equals(softwareRendering, "true", StringComparison.OrdinalIgnoreCase))
111 {
112 return;
113 }
114
115 RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;
116 }
117 }
118}