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

Communicating between threads

Hi,

I m kind of new to multithreading programming and try to implement one
solution. The problem I have is, I have one background thread which
does time consuming processing. The parent(calling) thread can be
windows application or console application or simple object. How can I
pass message from Background thread to parent thread. The message is
of type custom object so that I cant use BackgroundWorker class's
progress report method. I tried delegates but to update windows
control I have to use Invoke method. But I want the solution so
generic that when it come to parent they can directly update control
without considering threading in mind.

Any help is highly appreciated...thanks in advance..!!!

May 23 '07 #1
1 1675
<bh************@gmail.comwrote:
I m kind of new to multithreading programming and try to implement one
solution. The problem I have is, I have one background thread which
does time consuming processing. The parent(calling) thread can be
windows application or console application or simple object. How can I
pass message from Background thread to parent thread. The message is
of type custom object so that I cant use BackgroundWorker class's
progress report method. I tried delegates but to update windows
control I have to use Invoke method. But I want the solution so
generic that when it come to parent they can directly update control
without considering threading in mind.

Any help is highly appreciated...thanks in advance..!!!
You'll need Control.Invoke/BeginInvoke *somewhere* in order to marshal
the call back to the UI thread. However, you can provide helper methods
or properties to do that, so that clients don't have to worry about the
delegates themselves.

Console applications are different beasts - in that case although there
may be a separate thread which created the worker thread, there's no
default way provided to make a call within that thread - it's only the
fact that WinForms runs a message pump which makes it possible for GUI
apps. You can't just interrupt an arbitrary thread and tell it to
execute a different bit of code suddenly - it has to co-operatively be
waiting for delegates to run, effectively. All this can be done in a
console app, of course, but it's more work than in a WinForms app.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
May 23 '07 #2

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

Similar topics

1
by: Martin | last post by:
This is probably a very easy one but I just can't put my finger on the communicating events name:- I have a MDIform with a couple of child forms. The child forms scroll vertically at run time...
2
by: Eric Brunel | last post by:
Hi all, We're trying to communicate with Microsoft Visual C++ 6.0 via COM to make it perform a few operations. Our main need is to set a breakpoint on a given line in a given file. We ended up...
3
by: Michael Sparks | last post by:
Hi, I'm posting a link to this since I hope it's of interest to people here :) I've written up the talk I gave at ACCU Python UK on the Kamaelia Framework, and it's been published as a BBC...
0
by: David Dolheguy | last post by:
I have written an application using VB.Net 2003 which contains a single timer control (Interval set to 5 seconds) and a function which uses the BeginReceiveFrom Socket function. The problem I am...
1
by: valere | last post by:
I look for information for communicating between JavaScript and a native plugin. I noticed that LiveConnect is oriented to communicate as a "bridge" between Java and JS. But how to process with a...
3
by: Stan | last post by:
Hallo, I have developed an application in MS Access 2000 (Polish version) under MS Windows XP prof (also Polish). Now I would like to run this code on MS Windows XP EN and MS Access XP EN. I have...
6
by: Joe Jax | last post by:
I have an object that spawns a worker thread to process one of its methods. That method processes methods on a collection of other objects. During this processing, a user may request to cancel the...
5
by: jehugaleahsa | last post by:
Hello: I want to have a class that sends messages to a textbox. However, I want the message sender to be in a different thread than the message displayer, so users can scroll through the...
6
by: dolulob | last post by:
Hi, I'm trying to communicate with a console application through a c# program. the console application is micq a console based ICQ client. I want to be able to send an receive messages through...
2
by: aaronj1335 | last post by:
I am trying to write an application that controls a robot via a serial port. I made a robot class that includes the serial port over which I send commands, and I would like to be able to have...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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
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,...

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.