473,411 Members | 2,093 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

Re: Please suggest a Generic Cross-Thread Safe Invocation technique

On Thu, 26 Jun 2008 03:35:58 -0700, DeveloperX
<ia************@googlemail.comwrote:
Hello, this came up a few days ago, well similar. I suggested
SynchronizationContext briefly, I've found a blog post which explains
the ThreadBarrier pattern and may be of use.

http://blog.quantumbitdesigns.com/20...threadbarrier/

and also

http://blog.quantumbitdesigns.com/20...ier-revisited/
I think these articles are informative and useful food for thought.
However, they don't seem to really be applicable here, and I definitely
disagree with the implication that a) using Invoke() is "polluting the UI
thread" and especially b) that the proposed alternative, using the
SynchronizationContext class, avoids "polluting the UI thread". If
there's a pollution problem (and I don't feel that there is), the
SynchronizationContext approach has exactly the same problem that
Control.Invoke() does (seeing as they both wind up using the same
mechanisms).

In this particular message thread, there is a specific need to execute the
code on the GUI thread. There's no way around that. The simplest, most
straightforward way to do that is to simply call Invoke() with an
anonymous method that contains the code that needs to be executed.

It's good for people to know that SynchronizationContext exists and how to
use it. But in reality, Control.Invoke() (or Control.BeginInvoke()) is
sufficient and perfectly appropriate for most needs.
Peter, Google groups is working in Opera again :D
Yay! :) Still, you might eventually find that using a real newsreader is
better. :)

Pete
Jun 27 '08 #1
1 1658
On Jun 26, 7:30*pm, "Peter Duniho" <NpOeStPe...@nnowslpianmk.com>
wrote:
On Thu, 26 Jun 2008 03:35:58 -0700, DeveloperX *

<ianathomeag...@googlemail.comwrote:
Hello, this came up a few days ago, well similar. I suggested
SynchronizationContext briefly, I've found a blog post which explains
the ThreadBarrier pattern and may be of use.
http://blog.quantumbitdesigns.com/20...ting-the-ui-th...
and also
http://blog.quantumbitdesigns.com/20...g-ui-and-worke...

I think these articles are informative and useful food for thought. *
However, they don't seem to really be applicable here, and I definitely *
disagree with the implication that a) using Invoke() is "polluting the UI*
thread" and especially b) that the proposed alternative, using the *
SynchronizationContext class, avoids "polluting the UI thread". *If *
there's a pollution problem (and I don't feel that there is), the *
SynchronizationContext approach has exactly the same problem that *
Control.Invoke() does (seeing as they both wind up using the same *
mechanisms).

In this particular message thread, there is a specific need to execute the *
code on the GUI thread. *There's no way around that. *The simplest, most *
straightforward way to do that is to simply call Invoke() with an *
anonymous method that contains the code that needs to be executed.

It's good for people to know that SynchronizationContext exists and how to *
use it. *But in reality, Control.Invoke() (or Control.BeginInvoke()) is*
sufficient and perfectly appropriate for most needs.
Peter, Google groups is working in Opera again :D

Yay! *:) *Still, you might eventually find that using a real newsreader is *
better. *:)

Pete
Yep I take that on board, I've been playing with it in a mix of UI and
non UI contexts so it's quite interesting to me. I was semi wrong
about Opera being fixed. It works in standard view, but not tree view.
I'd love to use a real newsreader, but our pesky firewall is in the
way :( Fine at home of course.
Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: napsters | last post by:
Google uses some javascript for their Google Suggest service (http://www.google.com/webhp?complete=1&hl=en). When you type 'whatever', the script (http://www.google.com/ac.js, or, more readable,...
1
by: Lloyd Dupont | last post by:
due to cross reference I need to separate declaration and implementation. in my header I have something like that: --StyledRange.h-- generic <class T> ref class StyledRange; generic <class T>...
5
by: DelphiAddict | last post by:
Hi. Has anyone looked into generic factoring for making database independant applications? (Framework 2.0) I have, but I'm in the starting fase. What I do know is that if you only write...
3
by: ricolee99 | last post by:
Hi everyone, I have a problem that i have been trying to solve for awhile. I'm given a code where the purpose is to create a general dataset mapper. Given any dataset, i have a class,...
8
by: | last post by:
I'm looking for some design guidance on a collection of projects I'm working on. The project involves a bunch of websites constructed out of a collection of user controls. Different user...
15
by: Giggle Girl | last post by:
Hello there, :) I need a frameset that will have the same look and behavior in Firefox 1.5+ as it does in IE 6+. Here is a URL for it: http://66.51.164.93/fs/default.htm In IE, the "seam"...
3
by: Vincent Finn | last post by:
Hi, I am trying to write a generic function and it isn't behaving as expected. I want to avoid having to write custom convert functions for my enums so I want to convert to an int and cast to...
0
by: shapper | last post by:
Hello, I want to create an ordered list where each list item can have various controls: <ol> <li>textbox, label, ...</li> ... </ol>
15
by: Prisoner at War | last post by:
Okay, I'd like to create a print-friendly website, so I've been reading up on how to create print-friendly pages (without duplicating my site, of course, by having separate versions of each...
32
by: copx | last post by:
Why doesn't the C standard include generic function pointers? I use function pointers a lot and the lack of generic ones is not so cool. There is a common compiler extension (supported by GCC...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.