Skip to content
This repository has been archived by the owner on Jun 10, 2023. It is now read-only.

Commit

Permalink
Run download on taskpool, not dispatcher
Browse files Browse the repository at this point in the history
  • Loading branch information
j2ghz committed Aug 15, 2018
1 parent 68f801a commit 7b1f45b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
8 changes: 3 additions & 5 deletions src/ModSink.WPF/View/ModpackView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@
<TextBlock x:Name="TbName" FontSize="32" DockPanel.Dock="Top" Padding="5" />
<StackPanel Orientation="Horizontal" DockPanel.Dock="Top" Margin="2">
<TextBlock x:Name="TbSize" />
<mah:ToggleSwitch x:Name="ChkInstall"
Margin="15,5"
OffLabel="Download?"
OnLabel="Will be downloaded"
Style="{StaticResource MahApps.Metro.Styles.ToggleSwitch.Win10}" />
<ToggleButton
x:Name="ChkInstall"
Content="Download"/>
</StackPanel>
<ListBox x:Name="LbMods" />
</DockPanel>
Expand Down
4 changes: 2 additions & 2 deletions src/ModSink.WPF/View/ModpackView.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Reactive.Disposables;
using System.Windows.Controls.Primitives;
using ModSink.WPF.ViewModel;
using ReactiveUI;

Expand All @@ -14,8 +15,7 @@ public ModpackView()
{
this.OneWayBind(ViewModel, vm => vm.Modpack.Name, v => v.TbName.Text).DisposeWith(d);
this.OneWayBind(ViewModel, vm => vm.Size, v => v.TbSize.Text).DisposeWith(d);
this.OneWayBind(ViewModel, vm => vm.Modpack.Mods, v => v.LbMods.ItemsSource).DisposeWith(d);
this.Bind(ViewModel, vm => vm.Modpack.Selected, v => v.ChkInstall.IsChecked).DisposeWith(d);
this.BindCommand(ViewModel, vm => vm.Install, v => v.ChkInstall).DisposeWith(d);
});
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/ModSink.WPF/ViewModel/ModpackViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Linq;
using System.Threading.Tasks;
using Humanizer;
using Humanizer.Bytes;
using ModSink.Common.Models.Repo;
Expand All @@ -16,8 +17,12 @@ public ModpackViewModel(Modpack modpack)
.SelectMany(m => m.Mod.Files)
.Select(f => f.Value.Length)
.Aggregate((sum, a) => sum + a)).Humanize("G03");
Install = ReactiveCommand.CreateFromTask(() => Task.Run(() => Modpack.Selected = true),
outputScheduler: RxApp.TaskpoolScheduler);
}

public ReactiveCommand Install { get; }

public Modpack Modpack { get; }

public string Size { get; }
Expand Down

0 comments on commit 7b1f45b

Please sign in to comment.