// If you have install the code sniplets, use "propvm + [tab] +[tab]" create a property propcmd for command
        // 如果您已经安装了 MVVMSidekick 代码片段,请用 propvm +tab +tab 输入属性 propcmd 输入命令

        //IDisposable _currentTaskListening;
        public MainWindow_Model()
        {
            if (IsInDesignMode)
            {
                Messages.Add(new Models.MessageEntry {
                    Time = DateTime.Now, Message = "Message Here"
                });
                return;
            }
            GreaterFileShare.Hosts.WPF.Services.FileSystemHubService.vmInstance = this;
            var source1 = GlobalEventRouter.GetEventChannel <Exception>()
                          .Select(x =>
            {
                Exception[] rval = new[] { x.EventData };
                if (x.EventData is AggregateException)
                {
                    return(rval.Union((x.EventData as AggregateException).InnerExceptions));
                }
                return(rval);
            })
                          .SelectMany(x => x)
                          .Select(x => x.Message);

            var source2 = GlobalEventRouter.GetEventChannel <string>()
                          .Where(x => x.EventName == "Logging")
                          .Select(x => x.EventData);
            var source3 = new WebLoggingSource();

            new[] { source1, source2, source3 }
            .ToObservable()
            .SelectMany(ms => ms)
            .Select(x => new MessageEntry {
                Time = DateTime.Now, Message = x
            })
            .ObserveOnDispatcher()
            .Subscribe(x =>
            {
                Messages.Add(x);
                if (Messages.Count > 500)
                {
                    Messages.RemoveAt(0);
                }

                CurrentMessageIndex = Messages.Count - 1;
            })
            .DisposeWith(this);
            //CurrentTask.DisposeWith(this);
        }