protected ConsoleViewModel(int maxSize, Dispatcher dispatcher, Func <ObservableCollectionExtended <object>, BackgroundOutputDeviceMultiline> output) { MaxCount = maxSize; UiDispatcher = dispatcher ?? Dispatcher.CurrentDispatcher; _items = new ObservableCollectionExtended <object>(); _executeItemCommand = new RelayCommand <string>(Add, x => true); ClearCommand = new RelayCommand <object>(Clear, x => true); Output = output.Invoke(_items); }
public static Func <ObservableCollectionExtended <object>, BackgroundOutputDeviceMultiline> CreateOutputDevice() { return((collection) => { var outputDevice = new BackgroundOutputDeviceMultiline(Dispatcher.CurrentDispatcher, new OutputToCollection <object>(collection, collection.AddRange), null); outputDevice.TaskStartedAction = (d) => { Thread.CurrentThread.Name = $"{outputDevice.Name} {Thread.CurrentThread.ManagedThreadId}"; Thread.CurrentThread.Priority = ThreadPriority.BelowNormal; }; return outputDevice; }); }