static void ConnectAsync(ImpinjReader reader) { try { // Assign the ConnectAsyncComplete event handler. // This specifies which method to call // when the connection attempt has completed. reader.ConnectAsyncComplete += OnConnectAsyncComplete; // Attempt to connect to this reader asynchronously. // This method return immediately. // An event will be raised when the connect attempt has succeeded or failed. Console.WriteLine("Attempting connection to {0}", SolutionConstants.ReaderHostname); reader.ConnectAsync(SolutionConstants.ReaderHostname); // Wait for the user to press enter. Console.WriteLine("Press enter to exit."); Console.ReadLine(); } catch (OctaneSdkException e) { // Handle Octane SDK errors. Console.WriteLine("Octane SDK exception: {0}", e.Message); } catch (Exception e) { // Handle other .NET errors. Console.WriteLine("Exception : {0}", e.Message); } }
static void Main(string[] args) { try { // Pass in a reader hostname or IP address as a // command line argument when running the example if (args.Length != 1) { Console.WriteLine("Error: No hostname specified. Pass in the reader hostname as a command line argument when running the Sdk Example."); return; } string hostname = args[0]; // Assign the ConnectAsyncComplete event handler. // This specifies which method to call // when the connection attempt has completed. reader.ConnectAsyncComplete += OnConnectAsyncComplete; // Attempt to connect to this reader asynchronously. // This method return immediately. // An event will be raised when the connect attempt has succeeded or failed. Console.WriteLine("Attempting connection to {0}", hostname); reader.ConnectAsync(hostname); // Wait for the user to press enter. Console.WriteLine("Press enter to exit."); Console.ReadLine(); } catch (OctaneSdkException e) { // Handle Octane SDK errors. Console.WriteLine("Octane SDK exception: {0}", e.Message); } catch (Exception e) { // Handle other .NET errors. Console.WriteLine("Exception : {0}", e.Message); } }