You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
704 B

2 years ago
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DelegateEventFuncAction
{
public class EventTest
{
public delegate void CustomEventHandler(string message);
public event CustomEventHandler Trigger;
public event Action<string> TriggerByAction;
public void Notify()
{
Random rnd = new Random();
int r = rnd.Next(0, 10);
if (r <= 7 && this.Trigger != null)
this.Trigger("70% probability");
if (r <= 5 && this.TriggerByAction != null)
this.TriggerByAction("50% probability");
}
}
}