Solved

WPF Dispatcher

Posted on 2010-11-19
2
423 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

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

Suggested Solutions

Title # Comments Views Activity
How do I hide MVVM menu items in WPF/XAML? 1 54
c# DateTime Format validation 4 88
What!!!??? 5 59
How does this modal work? 3 33
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

737 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