static void Main(string[] args) { var transport = new TSocket("localhost", 9090); var protocol = new TBinaryProtocol(transport); var client = new LibraryService.Client(protocol); transport.Open(); var sw = new Stopwatch(); sw.Start(); var allBooks = client.GetAllBooks(); // Actual Thrift call sw.Stop(); long elapsedMilliseconds = sw.ElapsedMilliseconds; // var firstBook = client.GetBook(allBooks.First().Id); // Actual Thrift call }
private static void Main(string[] args) { var transport = new TSocket("localhost", 9090); var protocol = new TBinaryProtocol(transport); var client = new LibraryService.Client(protocol); transport.Timeout = 100; try { transport.Open(); var allBooks = client.GetAllBooks(); // Thrift call Console.WriteLine("Total number of books: {0}\n", allBooks.Count); if (allBooks.Count > 0) { Console.Write("Getting the first book: "); var firstBook = client.GetBook(allBooks.First().Id); // Thrift call Console.WriteLine("Id: {0}, {1} by {2}", firstBook.Id, firstBook.Title, firstBook.Author); } } catch (SocketException e) { Console.WriteLine("Could not connect to the server: {0}.", e.Message); } catch (Exception e) { Console.WriteLine("An error occured: {0}", e.Message); } Console.WriteLine("\nDone. Press any key to continue..."); Console.ReadKey(true); }