static Task DoBind0(IChannel channel, EndPoint localAddress) { // This method is invoked before channelRegistered() is triggered. Give user handlers a chance to set up // the pipeline in its channelRegistered() implementation. return(channel.EventLoop.SubmitAsync(async() => { try { await channel.BindAsync(localAddress); } catch (Exception) { channel.CloseAsync(); throw; } })); }
static Task DoBind0Async(IChannel channel, EndPoint localAddress) { // This method is invoked before channelRegistered() is triggered. Give user handlers a chance to set up // the pipeline in its channelRegistered() implementation. var promise = new TaskCompletionSource(); channel.EventLoop.Execute(() => { try { channel.BindAsync(localAddress).LinkOutcome(promise); } catch (Exception ex) { channel.CloseSafe(); promise.TrySetException(ex); } }); return(promise.Task); }