mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-07-10 07:40:34 +02:00
Fixed some kernel/splash screen async startup issues
This commit is contained in:
parent
87245d11fc
commit
3586c54e90
|
@ -66,15 +66,18 @@ namespace MediaBrowser.Controller
|
||||||
|
|
||||||
public async override Task Init(IProgress<TaskProgress> progress)
|
public async override Task Init(IProgress<TaskProgress> progress)
|
||||||
{
|
{
|
||||||
await base.Init(progress);
|
await Task.Run(async () =>
|
||||||
|
{
|
||||||
|
await base.Init(progress);
|
||||||
|
|
||||||
progress.Report(new TaskProgress() { Description = "Loading Users", PercentComplete = 15 });
|
progress.Report(new TaskProgress() { Description = "Loading Users", PercentComplete = 15 });
|
||||||
ReloadUsers();
|
ReloadUsers();
|
||||||
|
|
||||||
progress.Report(new TaskProgress() { Description = "Loading Media Library", PercentComplete = 20 });
|
progress.Report(new TaskProgress() { Description = "Loading Media Library", PercentComplete = 20 });
|
||||||
await ReloadRoot();
|
await ReloadRoot();
|
||||||
|
|
||||||
progress.Report(new TaskProgress() { Description = "Loading Complete", PercentComplete = 100 });
|
progress.Report(new TaskProgress() { Description = "Loading Complete", PercentComplete = 100 });
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnComposablePartsLoaded()
|
protected override void OnComposablePartsLoaded()
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<Application x:Class="MediaBrowser.ServerApplication.App"
|
<Application x:Class="MediaBrowser.ServerApplication.App"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
StartupUri="MainWindow.xaml">
|
|
||||||
<Application.Resources>
|
<Application.Resources>
|
||||||
|
|
||||||
</Application.Resources>
|
</Application.Resources>
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
using MediaBrowser.Common.Logging;
|
||||||
|
using MediaBrowser.Common.UI;
|
||||||
using MediaBrowser.Controller;
|
using MediaBrowser.Controller;
|
||||||
|
using MediaBrowser.Model.Progress;
|
||||||
using Microsoft.Shell;
|
using Microsoft.Shell;
|
||||||
|
|
||||||
namespace MediaBrowser.ServerApplication
|
namespace MediaBrowser.ServerApplication
|
||||||
|
@ -21,12 +25,50 @@ namespace MediaBrowser.ServerApplication
|
||||||
{
|
{
|
||||||
var application = new App();
|
var application = new App();
|
||||||
application.InitializeComponent();
|
application.InitializeComponent();
|
||||||
|
|
||||||
application.Run();
|
application.Run();
|
||||||
|
|
||||||
// Allow single instance code to perform cleanup operations
|
// Allow single instance code to perform cleanup operations
|
||||||
SingleInstance<App>.Cleanup();
|
SingleInstance<App>.Cleanup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected async override void OnStartup(StartupEventArgs e)
|
||||||
|
{
|
||||||
|
this.ShutdownMode = ShutdownMode.OnExplicitShutdown;
|
||||||
|
|
||||||
|
await LoadKernel();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task LoadKernel()
|
||||||
|
{
|
||||||
|
Progress<TaskProgress> progress = new Progress<TaskProgress>();
|
||||||
|
Splash splash = new Splash(progress);
|
||||||
|
|
||||||
|
splash.Show();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
DateTime now = DateTime.Now;
|
||||||
|
|
||||||
|
await new Kernel().Init(progress);
|
||||||
|
|
||||||
|
double seconds = (DateTime.Now - now).TotalSeconds;
|
||||||
|
|
||||||
|
Logger.LogInfo("Kernel.Init completed in {0} seconds.", seconds);
|
||||||
|
splash.Close();
|
||||||
|
|
||||||
|
this.ShutdownMode = System.Windows.ShutdownMode.OnLastWindowClose;
|
||||||
|
new MainWindow().ShowDialog();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show("There was an error launching Media Browser Server: " + ex.Message);
|
||||||
|
splash.Close();
|
||||||
|
Shutdown(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#region ISingleInstanceApp Members
|
#region ISingleInstanceApp Members
|
||||||
public bool SignalExternalCommandLineArgs(IList<string> args)
|
public bool SignalExternalCommandLineArgs(IList<string> args)
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
xmlns:tb="http://www.hardcodet.net/taskbar"
|
xmlns:tb="http://www.hardcodet.net/taskbar"
|
||||||
Title="MainWindow" Height="350" Width="525" AllowsTransparency="True" Background="Transparent" WindowStyle="None" ShowInTaskbar="False">
|
Title="MainWindow" Height="350" Width="525" AllowsTransparency="True" Background="Transparent" WindowStyle="None" ShowInTaskbar="False">
|
||||||
<Grid>
|
<Grid>
|
||||||
<tb:TaskbarIcon Name="MbTaskbarIcon" IconSource="/Icons/Icon.ico" ToolTipText="MediaBrowser Server" Visibility="Hidden">
|
<tb:TaskbarIcon Name="MbTaskbarIcon" IconSource="/Icons/Icon.ico" ToolTipText="MediaBrowser Server">
|
||||||
|
|
||||||
<tb:TaskbarIcon.ContextMenu>
|
<tb:TaskbarIcon.ContextMenu>
|
||||||
<ContextMenu Background="White">
|
<ContextMenu Background="White">
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
using System;
|
using System.Diagnostics;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using MediaBrowser.Common.Logging;
|
|
||||||
using MediaBrowser.Common.UI;
|
|
||||||
using MediaBrowser.Controller;
|
|
||||||
using MediaBrowser.Model.Progress;
|
|
||||||
|
|
||||||
namespace MediaBrowser.ServerApplication
|
namespace MediaBrowser.ServerApplication
|
||||||
{
|
{
|
||||||
|
@ -16,38 +11,7 @@ namespace MediaBrowser.ServerApplication
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
LoadKernel();
|
//LoadKernel();
|
||||||
}
|
|
||||||
|
|
||||||
private async void LoadKernel()
|
|
||||||
{
|
|
||||||
Progress<TaskProgress> progress = new Progress<TaskProgress>();
|
|
||||||
Splash splash = new Splash(progress);
|
|
||||||
|
|
||||||
splash.Show();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
DateTime now = DateTime.Now;
|
|
||||||
|
|
||||||
await new Kernel().Init(progress);
|
|
||||||
|
|
||||||
double seconds = (DateTime.Now - now).TotalSeconds;
|
|
||||||
|
|
||||||
Logger.LogInfo("Kernel.Init completed in {0} seconds.", seconds);
|
|
||||||
|
|
||||||
// Don't show the system tray icon until the kernel finishes.
|
|
||||||
this.MbTaskbarIcon.Visibility = System.Windows.Visibility.Visible;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show("There was an error launching Media Browser Server: " + ex.Message);
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
splash.Close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Context Menu events
|
#region Context Menu events
|
||||||
|
@ -66,7 +30,7 @@ namespace MediaBrowser.ServerApplication
|
||||||
|
|
||||||
private void cmExit_click(object sender, RoutedEventArgs e)
|
private void cmExit_click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
this.Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
Loading…
Reference in a new issue