?
Solved

WPF Dispatcher

Posted on 2010-11-19
2
Medium Priority
?
428 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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
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.…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses
Course of the Month14 days, 6 hours left to enroll

800 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