I wrap the library for my own use. To get a specific property, I need to wait for the event. I am trying to turn this into an asynchronous call.
Basically, I want to turn
void Prepare() { foo = new Foo(); foo.Initialized += OnFooInit; foo.Start(); } string Bar { return foo.Bar;
In that
async string GetBarAsync() { foo = new Foo(); foo.Initialized += OnFooInit; foo.Start();
How could this be achieved? I could just loop and wait, but I'm trying to find a better way, for example, using Monitor.Pulse (), AutoResetEvent, or something else.
c # asynchronous async-await
John-philip
source share