473,385 Members | 1,312 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,385 software developers and data experts.

Marshal data from thread, use...SynchronizationContext?

_DD
Existing problem: A function that runs on a thread needs to return
data to the UI thread. When the data is returned, that will trigger
secondary tasks, including access to form controls and lookup of data
within a database.

I'm not sure of the implications of using data returned by the thread
within database access code, but I do know about InvokeRequired() etc
for access to forms controls. I've used that often when individual
controls are the focal point. Not so here.

In this case, I'd like to simplify things by marshaling ALL data
coming back from the thread. Then it could be used by controls or
other functions with no worries. So the thread would return data
through a 'channel object' that takes care of all marshaling in one
place.

As for the mechanics involved:

InvokeRequired() is associated with a specific control, so that is not
relevant.

BackgroundWorker seems like it might be applicable, but I haven't seen
it used in the context, maybe for good reason.

SynchronizationContext seems like a good clue but I have not been able
to find enough info on actual usage to be sure that this is the
simplest approach.

Thanks for any perspective you can provide.

Apr 24 '06 #1
1 3010
InvokeRequired is NOT associated with a single control.
It is associated with the UI thread that created the control.
In a typical application that will be the ONLY UI thread.

To keep it as general as possible pass the ISychronizeInvoke interface to
your work thread rather than an actual control.

SynchronizationContext is just a property holding an ISynchronizeInvoke for
exactly this purpose.

"_DD" <_D*@nospamforme.com> wrote in message
news:0q********************************@4ax.com...
Existing problem: A function that runs on a thread needs to return
data to the UI thread. When the data is returned, that will trigger
secondary tasks, including access to form controls and lookup of data
within a database.

I'm not sure of the implications of using data returned by the thread
within database access code, but I do know about InvokeRequired() etc
for access to forms controls. I've used that often when individual
controls are the focal point. Not so here.

In this case, I'd like to simplify things by marshaling ALL data
coming back from the thread. Then it could be used by controls or
other functions with no worries. So the thread would return data
through a 'channel object' that takes care of all marshaling in one
place.

As for the mechanics involved:

InvokeRequired() is associated with a specific control, so that is not
relevant.

BackgroundWorker seems like it might be applicable, but I haven't seen
it used in the context, maybe for good reason.

SynchronizationContext seems like a good clue but I have not been able
to find enough info on actual usage to be sure that this is the
simplest approach.

Thanks for any perspective you can provide.

Apr 24 '06 #2

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

Similar topics

14
by: Notre Poubelle | last post by:
Hello, I have a worker thread that needs to call a method that only works on the main/UI thread. One way to accomplish this in managed code is to use Control.Invoke. However, in my case I...
6
by: HolyShea | last post by:
All, Not sure if this is possible or not - I've created a class which performs an asynchronous operation and provides notification when the operation is complete. I'd like the notification to be...
1
by: Frankie | last post by:
I have been learning about asynchronous method calls and I keep coming across this term, "marshal" and I would like to know what it means - specifically. AFAIKT, it means "send" but I suspect there...
1
by: Peter Duniho | last post by:
On Thu, 26 Jun 2008 03:35:58 -0700, DeveloperX <ianathomeagain@googlemail.comwrote: I think these articles are informative and useful food for thought. However, they don't seem to really be...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.