// Create a new TProtocol instance and set it to read from a MemoryStream TProtocol protocol = new TBinaryProtocol(new TMemoryBuffer()); // ... write some data to the protocol stream ... // Asynchronously read a 64-bit integer from the protocol stream long result = await protocol.ReadI64Async();
// Create a new HttpClient instance and a new ThriftHttpClient instance HttpClient httpClient = new HttpClient(); ThriftHttpClient thriftClient = new ThriftHttpClient(httpClient, "https://example.com/thrift/service"); // ... create a request and serialize it using thriftClient ... // Asynchronously send the request and receive a response SomeResponse response = await thriftClient.RequestAsyncIn this example, we use the ThriftHttpClient class to send a Thrift request over HTTP to a remote service located at https://example.com/thrift/service. We create a request object and serialize it using the thriftClient instance, then use the RequestAsync method to asynchronously send the request and receive a response. Within the RequestAsync method, we use a lambda expression to write the request to the protocol stream and then use the ReadI64Async method to asynchronously read a 64-bit integer from the response stream. Package library: Apache Thrift for C#.(request => { request.Write(thriftClient.Protocol); return thriftClient.Protocol.ReadI64Async(); });