public void StartConnection(Action <BillingResult> setupFinished, Action onDisconnected) { var listener = new InternalBillingClientStateListener { BillingServiceDisconnectedHandler = () => onDisconnected?.Invoke(), BillingSetupFinishedHandler = r => setupFinished?.Invoke(r) }; StartConnection(listener); }
public Task <BillingResult> StartConnectionAsync(Action onDisconnected = null) { var tcs = new TaskCompletionSource <BillingResult>(); var listener = new InternalBillingClientStateListener { BillingServiceDisconnectedHandler = () => { onDisconnected?.Invoke(); tcs.TrySetResult(null); }, BillingSetupFinishedHandler = r => tcs.TrySetResult(r) }; StartConnection(listener); return(tcs.Task); }