I was reviewing some WPF code I've written in C# last year.The scenario is the following:I've got a usercontrol that show usermessages and it's docked in the bottom of the application's workspaceI've got a ConcurrentQueue that receives message via a IMessageMediator (from Catel, but's irrilevant how data are pushed)I've a workerprocess that checks if there's some item in the queue and add them to a list that's bound to a gridprivate readonly ConcurrentQueue<UserMessage> queue;private readonly List<UserMessage> dataItems;private void worker_DoWork(object sender, DoWorkEventArgs e){    while (true)    {        if (!queue.IsEmpty)        {            UserMessage message;            while (queue.TryDequeue(out message))            {                dataItems.Add(message);            }            RaisePropertyChanged(() => FilteredDataItems);            RaisePropertyChanged(() => ErrorCountMessage);            RaisePropertyChanged(() => WarningsCountMessage);        }        Thread.Sleep(500);    }}//That's used to show only filtered items (Error/Warning....)public IEnumerable<UserMessage> FilteredDataItems{    get    {        if (!enabledFilters.Any())            return dataItems;        return dataItems.Where(x => enabledFilters.Contains(x.LogMessageType));    }}How can I remove this while(true) and the ugly/odd Thread.Sleep(500)?
Removing this odd while(true) for checking the queue
c#;wpf