✅ Making custom Events

I am working with a pi using the System.Device.Gpio. is there a way to create an event for when a pin changes?

I have never worked with making events only ever subscribed to known events, so i don't know if you even can, but I dont see why you couldn't.

the GPIO library has 2 functions. waitForEvent, and waitForEventAsync. Previously I just made a task list like this: (This is a poor rendition, these functions would do alot more)

void async main()
{
List<task> tasks = new List<Task>();
tasks.add(ListenAsync);
tasks.add(Listen2Async);
await Task.WhenAll(Tasks)
}

async Task ListenAsync()
{
  return controller.WaitForEventAsync(...)
}

this seems wrong, and if I could just make a pinChange event and subscribe a method to it, it would be alot easier. Effectively like an interrupt.

TLDR
What is the correct way to look for pin chages? should i just stick with making a list of tasks, or is there a way to make an event system for pin changes?
Was this page helpful?