public ViewFilter() { Filter = new Filter(); Filter.FilterChanged += delegate { RebuildCurrentViewAsync(); }; Messages = new ThreadSafeCollection<Message>(); mailbox = VirtualMailBox.Current; mailbox.InboxLoadComplete += delegate { // Perform a lock-free update on the UI-Thread. // We should be safe because at this point there should be no async tasks // running and all inserts should happen on the UI thread anyway. Messages.Replace(GetMessagesInView( mailbox.Messages.Where(IsMessageVisible).AsQueryable()).ToList()); }; signal = new AutoResetEvent(false); workerThread = new Thread(RenderView) { Name = "View rendering thread", IsBackground = true, Priority = ThreadPriority.Normal }; workerThread.Start(); }
public ViewFilter() { Filter = new Filter(); Filter.FilterChanged += delegate { RebuildCurrentViewAsync(); }; Messages = new ThreadSafeCollection <Message>(); mailbox = VirtualMailBox.Current; mailbox.InboxLoadComplete += delegate { // Perform a lock-free update on the UI-Thread. // We should be safe because at this point there should be no async tasks // running and all inserts should happen on the UI thread anyway. Messages.Replace(GetMessagesInView( mailbox.Messages.Where(IsMessageVisible).AsQueryable()).ToList()); }; signal = new AutoResetEvent(false); workerThread = new Thread(RenderView) { Name = "View rendering thread", IsBackground = true, Priority = ThreadPriority.Normal }; workerThread.Start(); }
public void LoadData(object data) { searchQuery = ((ColumnSearchDataHelper)data).SearchQuery; if (String.IsNullOrEmpty(searchQuery)) { messages.Clear(); documents.Clear(); persons.Clear(); statusUpdates.Clear(); return; } dock.SearchQuery = searchQuery; OnPropertyChanged("Title"); var searchMessages = ClientState.Current.Search.PerformSearch <Message>(searchQuery) .Select(id => mailbox.Messages.FirstOrDefault(m => m.MessageId == id)) .Where(doc => doc != null) .ToList(); var searchDocuments = ClientState.Current.Search.PerformSearch <Document>(searchQuery) .Select(id => mailbox.Documents.FirstOrDefault(d => d.DocumentId == id)) .Where(doc => doc != null) .ToList(); var searchPersons = ClientState.Current.Search.PerformSearch <Person>(searchQuery) .Select(id => mailbox.Persons.FirstOrDefault(p => p.PersonId == id)) .Where(p => p != null) .ToList(); var searchStatusUpdates = ClientState.Current.Search.PerformSearch <UserStatus>(searchQuery) .Select(id => mailbox.StatusUpdates.FirstOrDefault(s => s.StatusId == id)) .Where(s => s != null) .ToList(); messages.Replace(searchMessages); documents.Replace(searchDocuments); persons.Replace(searchPersons); statusUpdates.Replace(searchStatusUpdates); }