Files
WPF_Practice/PacticeSolution/DelegateEventFuncAction/EventTest.cs
2023-07-31 15:19:10 +09:00

30 lines
704 B
C#

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");
}
}
}