private async Task SendAsyncAndUnwrapExceptions(SharedBuffer buffer)
        {
            using (ApiStatus status = new ApiStatus())
            {
                try
                {
                    await this.SendAsync(buffer);
                }
                catch (RLException e)
                {
                    e.UpdateApiStatus(status);
                    this.RaiseBackgroundError(status);
                }
                catch (Exception e)
                {
                    ApiStatusBuilder builder = new ApiStatusBuilder(NativeMethods.OpaqueBindingError)
                                               .AppendLine(e.Message)
                                               .AppendLine(e.StackTrace);
                    builder.UpdateApiStatus(status);

                    this.RaiseBackgroundError(status);
                }
            }

            GC.KeepAlive(buffer);
        }
        public void Send(SharedBuffer buffer, ApiStatus status)
        {
            // Create a cloned handle so that we have our own copy of the shared pointer to the buffer
            SharedBuffer ownedHandle = new SharedBuffer(buffer);

            GC.KeepAlive(buffer);

            // Fire off the send task, and return
            Task backgroundTask = SendAsyncAndUnwrapExceptions(ownedHandle);
        }
 protected abstract Task SendAsync(SharedBuffer buffer);