Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7733401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:58:44+00:00 2026-06-01T06:58:44+00:00

I have a standard Listbox which is bound to a property in my viewmodel

  • 0

I have a standard Listbox which is bound to a property in my viewmodel

   <ListBox ItemsSource="{Binding StatusList, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"  Name="myListBox"  BorderThickness="0" HorizontalAlignment="Stretch">        
                </ListBox>

The property

 private ObservableCollection<String> _statusList;
        public ObservableCollection<String> StatusList
        {
            get { return _statusList;}
            set { _statusList = value;}
        }

The view model subscribes to an event

  _eventAggregator.GetEvent<PublishStatusEvent>().Subscribe(this.OnStatusChanged);

which excecutes a function that just adds strings to the collection

 private void OnStatusChanged(string status)
        {
            StatusList.Add(status);
        }

When i exceute a long running task that publishes events , i want the listbox to update. If i debug i can see the events coming but the listbox is not getting updated until the task is finished. The task is inititated in the viewmodel.

Anyone?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T06:58:46+00:00Added an answer on June 1, 2026 at 6:58 am

    I’m guessing that your ‘long running task’ is actually running on the UI thread and therefore blocking the UI thread even though you’re successfully publishing and subscribing events. This would explain why the events all appear when the task completes.

    Try moving your task to another thread, maybe something like this:

    public class MyViewModel
    {
        private readonly IEventAggregator _aggregator;
    
        public MyViewModel(IEventAggregator aggregator)
        {
            _aggregator = aggregator;
            var tf = new TaskFactory();
            tf.StartNew(SendStatusMessages);
        }
    
        private void SendStatusMessages()
        {
            for (int i = 0; i < 50; i++)
            {
                Thread.Sleep(1000);
    
                var s = "item: " + i;
                Debug.WriteLine("Sending" + s);
                _aggregator.GetEvent<StatusEvent>().Publish(s);
            }
        }
    

    You will then need to change your subscription code, as suggested by @shriek, to

    _aggregator.GetEvent<PublishStatusEvent>().Subscribe(
         OnStatusChanged, ThreadOption.UIThread);
    

    The fact that you hadn’t specified ThreadOption.UIThread and weren’t getting a thread exception when adding an item to the status list also indicates that your task is currently on the UI thread.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have standard source code package under Linux which requires to run ./configure make
Is it possible to have standard war deployment, which can be deployed on tomcat
I made a ListBox with your standard smart-control thing, and have it connected to
I have a listbox with a lot of items which are expensive to render.
I have standard basic article content type which, amongst other things, contains an image
I have what I think is a fairly standard setup, a ListBox backed by
I have a Listbox with 3 columns on an access form which has as
I have standard text links which all say Full View. When clicked these links
We have a standard Access listbox with multiple columns. Is there a way to
In my Windows Phone application I have a listBox with ContentItems binding : private

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.