C
C#2y ago
mohamed

❔ Help create a signals(event) system

Hello there I am trying to recreate a signal system like the one in Godot Basically you can do something like this with it
async void SomeMethod(){

// do stuff

await Signal("signal_name");

// continue doing other stuff

}
async void SomeMethod(){

// do stuff

await Signal("signal_name");

// continue doing other stuff

}
and the function would suspend until the user call EmitSignal("signal_name") I tried recreating it but no luck can anyone help me or show me how to use Task or IAwaitable to do this
6 Replies
Thinker
Thinker2y ago
You know C# already has events, right?
mohamed
mohamed2y ago
@thinker227 Yeah But they are basically a list of methods you cant suspend/resume a method with them
Anton
Anton2y ago
use TaskCompletionSource
mohamed
mohamed2y ago
@mohamed I found people saying to use it but I don't really understand how it works
Anton
Anton2y ago
it helps you turn events into tasks ah shoot you got me fired I kinda wanted to do this thing myself for a long time
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts