SampSharp
SampSharp copied to clipboard
Add GlobalObject.EditAsync like the Dialog.ShowAsync
It would be great to work with the object edit awaiting it instead of using events. Just like in the dialogs.
Example:
await myObject.EditAsync();
Console.WriteLine("Finished editing");
Great idea, I'll look into it.
An temporary work around, you can use TaskCompletitionSource<TResult>
in events to handle that.
var tcs = new TaskCompletitionSource();
SomeEventHandler handler = null;
handler = (sender, args) =>
{
//do stuff
obj.SomeEvent -= handler;
tcs.TrySetResult(); // notify to complete task.
};
obj.SomeEvent += handler;
await tcs.Task;