예제 #1
0
        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);
        }
예제 #2
0
        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;
            });
        }