Dispose() public method

public Dispose ( ) : void
return void
Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var driver = new MyDriverClient("jeffz://server:12345");

            try
            {
                driver.Connect();
                driver.AddQuery(1);
                driver.AddQuery(2);
                driver.AddQuery(3);
            }
            catch
            {
                driver.Dispose();
                Console.WriteLine("Error occurred when connect or add query.");
                Environment.Exit(1);
            }

            new Thread(() => ReceiveData(driver)).Start();
        }
Exemplo n.º 2
0
 private static void ReceiveData(MyDriverClient driver)
 {
     try
     {
         while (true)
         {
             var data = driver.Receive();
             if (data == null)
             {
                 Console.WriteLine("Closed");
                 break;
             }
             else
             {
                 Console.WriteLine(data);
             }
         }
     }
     catch (MyDriverException)
     {
         driver.Dispose();
         Console.WriteLine("Error occurred when receive data.");
     }
 }