Solved

WPF Dispatcher

Posted on 2010-11-19
2
426 Views
Last Modified: 2012-05-10
Hi
I need som help with this code.

How do I write the Dispatcher for this listbox I have?
private void StatusUpdates(string message)
        {
            if (this.uxStatusUpdate.Dispatcher.Thread == Thread.CurrentThread)
            {
                this.uxStatusUpdate.Items.Add(message);
            }
            else
            {
                this.uxStatusUpdate.Dispatcher.BeginInvoke ????            
            }
        }

Open in new window

0
Comment
Question by:AWestEng
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 34177721
Here's one way:
*Note the delegate I declared above StatusUpdates()!
private delegate void StatusUpdatesDelegate(string message);

        private void StatusUpdates(string message)
        {
            if (this.uxStatusUpdate.Dispatcher.Thread == Thread.CurrentThread)
            {
                this.uxStatusUpdate.Items.Add(message);
            }
            else
            {
                this.uxStatusUpdate.Dispatcher.BeginInvoke(new StatusUpdatesDelegate(StatusUpdates), new Object[] { message });
            }
        }

Open in new window

0
 
LVL 1

Author Closing Comment

by:AWestEng
ID: 34179207
thx man
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question