SampSharp icon indicating copy to clipboard operation
SampSharp copied to clipboard

Add GlobalObject.EditAsync like the Dialog.ShowAsync

Open KirillBorunov opened this issue 3 years ago • 2 comments

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");

KirillBorunov avatar Nov 25 '21 19:11 KirillBorunov

Great idea, I'll look into it.

ikkentim avatar Nov 25 '21 20:11 ikkentim

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;

nathan130200 avatar Mar 30 '22 11:03 nathan130200