473,406 Members | 2,217 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,406 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 1321


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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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
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
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...

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.