473,473 Members | 2,159 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 1660
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
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.