donato
New member
- Joined
- Jun 23, 2020
- Messages
- 1
- Programming Experience
- 10+
Hi,
I'm using an event to execute a method "c_ThresholdReached" if I press a button, code example:
the output on console system is:
in OnThresholdReached
The threshold was reached.
out OnThresholdReached
the question is: if is it possible to complete the execution of method " button_Click " and subsequently is executed the method "c_ThresholdReached" raised from the event?
I'm using an event to execute a method "c_ThresholdReached" if I press a button, code example:
C#:
public event EventHandler ThresholdReached;
protected virtual void OnThresholdReached(EventArgs e)
{
EventHandler handler = ThresholdReached;
if (handler != null)
{
handler.Invoke(this, e);
}
}
static void c_ThresholdReached(object sender, EventArgs e)
{
Console.WriteLine("The threshold was reached.");
}
private void button_Click(object sender, EventArgs e)
{
ThresholdReached += c_ThresholdReached;
System.Console.WriteLine("in OnThresholdReached");
OnThresholdReached(EventArgs.Empty);
System.Console.WriteLine("out OnThresholdReached");
}
in OnThresholdReached
The threshold was reached.
out OnThresholdReached
the question is: if is it possible to complete the execution of method " button_Click " and subsequently is executed the method "c_ThresholdReached" raised from the event?
Last edited by a moderator: