Fix CanGenerate
This commit is contained in:
@@ -6,10 +6,13 @@ namespace LaDOSE.DesktopApp.Utils
|
||||
{
|
||||
public static class WpfUtil
|
||||
{
|
||||
public static void AddUI<T>(this ICollection<T> collection, T item)
|
||||
public static void AddUI<T>(this ICollection<T> collection, T item, Action action = null)
|
||||
{
|
||||
Action<T> addMethod = collection.Add;
|
||||
Application.Current.Dispatcher.BeginInvoke(addMethod, item);
|
||||
}
|
||||
if(action!=null)
|
||||
Application.Current.Dispatcher.BeginInvoke(action);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -72,13 +72,14 @@ namespace LaDOSE.DesktopApp.ViewModels
|
||||
Players.Clear();
|
||||
PlayersOptions.Clear();
|
||||
|
||||
Task.Factory.StartNew(LoadPlayers, TaskCreationOptions.LongRunning).ContinueWith(t => { },
|
||||
CancellationToken.None, TaskContinuationOptions.OnlyOnFaulted,
|
||||
Task.Factory.StartNew(LoadPlayers, TaskCreationOptions.LongRunning).ContinueWith(
|
||||
t => { NotifyOfPropertyChange(() => this.CanGenerate); },
|
||||
CancellationToken.None, TaskContinuationOptions.OnlyOnRanToCompletion,
|
||||
TaskScheduler.FromCurrentSynchronizationContext());
|
||||
NotifyOfPropertyChange(() => SelectedGame);
|
||||
NotifyOfPropertyChange(() => this.CanGenerate);
|
||||
NotifyOfPropertyChange(() => Players);
|
||||
NotifyOfPropertyChange(() => PlayersOptions);
|
||||
NotifyOfPropertyChange(() => this.CanGenerate);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,13 +197,9 @@ namespace LaDOSE.DesktopApp.ViewModels
|
||||
var findUser = FindUser(SelectedWpEvent.Id, SelectedGame);
|
||||
var findUser2 = FindUser(SelectedWpEvent.Id, SelectedGame,true);
|
||||
|
||||
findUser.ForEach((e) => this.Players.AddUI(e));
|
||||
findUser.ForEach((e) => this.Players.AddUI(e,()=>NotifyOfPropertyChange(() => this.CanGenerate)));
|
||||
findUser2.ForEach((e) => this.PlayersOptions.AddUI(e));
|
||||
//this.RestService.GetUsers(SelectedWpEvent.Id, SelectedGame.Id)
|
||||
// .ForEach((e) => this.Players.AddUI(e));
|
||||
//this.RestService.GetUsersOptions(SelectedWpEvent.Id, SelectedGame.Id)
|
||||
// .ForEach((e) => this.PlayersOptions.AddUI(e));
|
||||
NotifyOfPropertyChange(() => this.CanGenerate);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user