Return an object from a dialog

I want to return an object from a dialog

 var res = await DialogService.OpenAsync<CreateCustomerComponent>("Create Customer");

In my dialog

 private void HandleValidSubmit()
 {
     DialogService.Close(Customer);
 }

I get "true" returned not my Customer object

You can change and check this demo for reference:

https://blazor.radzen.com/dialog

Thanks I read the example. Never ask without reading the manual :wink:
Do I need to attach an eventhandler? There are now way to return the value to the calling method?

public Task<object> OpenAsync<T>(
  string title,
  Dictionary<string, object> parameters = null,
  DialogOptions options = null)
  where T : ComponentBase
{
  TaskCompletionSource<object> completionSource = new TaskCompletionSource<object>();
  this.tasks.Add(completionSource);
  this.OpenDialog<T>(title, parameters, options);
  return completionSource.Task;
}

Can I not get the dialog value return from the TaskCompletionSource from the function signature it looks like the object can be my return object.

I would really like to avoid using delegates the always led to memory leeks.


Thanks again I was a little slow
Really appreciate your support

This is my working code.

private async Task AddContact()
{
    var objAsync = await DialogService.OpenAsync<CreateContact>("Create Contact");
    if(!objAsync is Contact || objAsync == null)
        return;
    var added = await ContactService.AddContact((Contact) objAsync);
}