There is this class unit
that has a property bool status
that marks whether a method, request
, should be called on the unit. I have my other class, and in it, there is a method that should call request
. To avoid blocking the main thread, I want to call the method asynchronously. The problem is that there isn't an event for the status change, and I don't want to make my asynchronous call do ugly stuff like:
while(!status){}unit.request(args);
or
while(!status){Thread.Sleep(100)}unit.request(args);
especially when I do not know the timescale in which status
turns true
.
How do I do this?
update: i forgot to mention that i cannot change unit
. sorry for that.