469,921 Members | 2,183 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,921 developers. It's quick & easy.

execution of events

Hi,

Background.
In an engineering application I consider using events to
control the flow in the program under the following
philosophy: When a value X change it fires a "i'm
changed" event. A value Y will is a function of X and
will therefore subscribe to X-changed event. Y will
recalculate and fire its own "i'm changed" in order for
other values dependent on Y to recalculate. This would be
a good solution to the nature of my project.
Like

A = 5
Fire A chaged

capture A Changed
B = 5 * A
fire B changed

capture B changed
C = B*B
I have the following question:
Is the firing of an event equal to call a procedure, i.e.
will the execution immediately go a subscriber of the
event and then return or will it start a new thread.

best regards Jesper.
Nov 15 '05 #1
1 1688
100
Hi Jesper,
You can do either. If you declare an event and call the event as a normal
method it will execute the event in the same thread and it will be just like
calling a procedure. If you want to execute the event handler in a separate
thread you can use delegate's (in this case event's) BeginInvoke and
EndInvoke methods.

for example if you have an event ValueChanged:

public event EventHandler ValueChanged;

if you do:
ValueChanged(this, EventArgs.Empty);
this will execute any event handler in the same thread as a normal
procedure.

if you do:
ValueChanged.BeginInvoke(......) ;
this will start the event handlers in a separate thread from the thread pool

HTH
B\rgds
100;

"Jesper" <je****@hotmail.com> wrote in message
news:05****************************@phx.gbl...
Hi,

Background.
In an engineering application I consider using events to
control the flow in the program under the following
philosophy: When a value X change it fires a "i'm
changed" event. A value Y will is a function of X and
will therefore subscribe to X-changed event. Y will
recalculate and fire its own "i'm changed" in order for
other values dependent on Y to recalculate. This would be
a good solution to the nature of my project.
Like

A = 5
Fire A chaged

capture A Changed
B = 5 * A
fire B changed

capture B changed
C = B*B
I have the following question:
Is the firing of an event equal to call a procedure, i.e.
will the execution immediately go a subscriber of the
event and then return or will it start a new thread.

best regards Jesper.

Nov 15 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by john bailo | last post: by
4 posts views Thread by Pham Nguyen | last post: by
3 posts views Thread by Suzanne Boyle | last post: by
5 posts views Thread by John | last post: by
23 posts views Thread by roman | last post: by
7 posts views Thread by Andrew Poulos | last post: by
reply views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.