Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 protected abstract Task SendAsync(SharedBuffer buffer);