/// <summary> /// Responses command to the server. /// </summary> /// <param name="clientHandle">The client handle.</param> /// <param name="result">The result of each command.</param> /// <param name="bundle">The extra data.</param> internal void Response(NativeClientHandle clientHandle, int result, Bundle bundle) { try { if (bundle != null) { NativeClient.SendCustomEventReplyBundle(clientHandle, ReceiverId, _requestId, result, bundle.SafeBundleHandle) .ThrowIfError("Failed to response event."); } else { NativeClient.SendCustomEventReply(clientHandle, ReceiverId, _requestId, result, IntPtr.Zero) .ThrowIfError("Failed to response event."); } } catch (ArgumentException) { throw new InvalidOperationException("Server is not running"); } finally { OnResponseCompleted(); } }