.NETGURU
What is the best way to update UI from different thread?
Messages   Related Types
This message was discovered on microsoft.public.dotnet.languages.csharp.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...

Julia
Hi,

I have an application which run 3 different thread.
the main application display a window like a console window
in VS.NET.
I would like that each thread will write to this window details about it's
progress and status.
I wonder what to choose

1.BeginInvoke.
2.Invoke-will halt the calling thread isn't it?
3.Writing to a thread safe queue,use another thread to read from the queue
and output it in the main thread

Thanks.

Reply to this message...
 
    
Richard Blewett [DevelopMentor] (VIP)
Prefer Control.BeginInvoke every time.

Using Invoke it?s not that hard to end up in a thread deadlock. And why would the calling thread want to wait around for the UI update to occur?

And as for a queue - well that?s what BeginInvoke is doing - only via the Windows message queue rather than a CLR based one.

Regards

Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog

nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/

Hi,

I have an application which run 3 different thread.
the main application display a window like a console window in VS.NET.
I would like that each thread will write to this window details about it's progress and status.
I wonder what to choose

1.BeginInvoke.
2.Invoke-will halt the calling thread isn't it?
3.Writing to a thread safe queue,use another thread to read from the queue and output it in the main thread

Thanks.

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.760 / Virus Database: 509 - Release Date: 10/09/2004

[microsoft.public.dotnet.languages.csharp]

Reply to this message...
 
    
Jon Skeet [C# MVP] (VIP)
Richard Blewett [DevelopMentor] <Click here to reveal e-mail address> wrote:
[Original message clipped]

Only if you don't follow the rule of "don't call Invoke while holding a
lock". It's not hard to make sure you don't deadlock, in my experience.

[Original message clipped]

That's a much better reason to use BeginInvoke, of course.

--
Jon Skeet - <Click here to reveal e-mail address>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Reply to this message...
 
 
System.Web.UI.Control




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification