473,385 Members | 1,582 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.

thread events

How can I trigger event form thread and catch it in another thread

Simple scenario:

Thread "X" running …
Thread "Y" running …
Thread "X" triggering Event "W"
Thread "Y" catches Event "W"
Thread "X" running …
Thread "Y" processing Event "W"
Thread "Y" running …
Thread "X" running …
..
..
..
Can I implement this problem using normal event handling or am I forced to
use special way?!

C# preferred in code example
Thank you!

Aug 20 '05 #1
3 1320


aibras wrote:
How can I trigger event form thread and catch it in another thread
C# events are not "catched", they are "run" by the thread that invokes
them. If you wish to run them asynchroneously you will have to use the
constructs available for async calls: Thread or .BeginInvoke.

You can have the event place data somewhere shared and use a Mutex or
the Monitor pattern to protect that shared data and communicate that
data is available.

Beware that the C# event concept has serious mutithreading problems,
read more about that in microsoft.public.languages.csharp.
Can I implement this problem using normal event handling or am I forced to
use special way?!
"Special"
C# preferred in code example


Is this homework?

--
Helge Jensen
mailto:he**********@slog.dk
sip:he**********@slog.dk
-=> Sebastian cover-music: http://ungdomshus.nu <=-
Aug 22 '05 #2
Thank you Helge
Actually it is not homework.
It just problem I discuss it with my friend one day while dinner ^_^.

Aug 23 '05 #3
You can notify other threads using pulse.

http://msdn.microsoft.com/library/de...pulsetopic.asp

"aibras" <ai****@discussions.microsoft.com> wrote in message
news:2B**********************************@microsof t.com...
How can I trigger event form thread and catch it in another thread

Simple scenario:

Thread "X" running .
Thread "Y" running .
Thread "X" triggering Event "W"
Thread "Y" catches Event "W"
Thread "X" running .
Thread "Y" processing Event "W"
Thread "Y" running .
Thread "X" running .
.
.
.
Can I implement this problem using normal event handling or am I forced to
use special way?!

C# preferred in code example
Thank you!

Oct 19 '05 #4

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

Similar topics

0
by: Steven Brown | last post by:
I'm trying to figure out how to safely use .NET events/delegates in a thread-safe class. There are a couple problems. One is that the standard "if(EventName != null) EventName(...);" call can...
12
by: Ricardo Pereira | last post by:
Hello all, I have a C# class (in this example, called A) that, in its constructor, starts a thread with a method of its own. That thread will be used to continuously check for one of its...
4
by: Stirling | last post by:
I have a main worker thread that spawns a child thread to do some listening. What I would like to have happen is to have the child thread raise events in the parent thread, and have the parent...
7
by: Ram | last post by:
Hi, I have two threads, one parent thread containing UI and a child thread waiting for some events from the parent thread. Now, I have two issues: 1) to keep the child thread active till the end...
1
by: Tom | last post by:
First of all, is it 'legal' (i.e. thread-safe) to pass events back from a worker thread to the main thread? I.E. Can one put PUBLIC EVENT XYZ in their worker thread and then raise that event for...
0
by: puff | last post by:
When interfacing to a COM object, is it possible to pump messages in a thread? I'm working on an application that automates IE and needs to monitor IE events (yes I know about Pamie). I'm able...
4
by: sklett | last post by:
I'm fairly new to Threading and things have been going pretty smooth so far. I did some performance testing on my new app and realized it's lagging a bit on raising events. It's a realtime app and...
5
by: Tony Gravagno | last post by:
I have a class that instantiates two Timer objects that fire at different intervals. My class can be instantiated within a Windows Form or from a Windows Service. Actions performed by one of the...
11
by: mark | last post by:
Right now I have a thread that sleeps for sometime and check if an event has happened and go back to sleep. Now instead I want the thread to sleep until the event has occured process the event and...
1
by: raghudr | last post by:
Hi all, I am displaying a splash screen for which i have created a thread.Since my whole project is launched by windows service and that service will start automatically at the start of the...
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
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.