using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using OpcLabs.EasyOpc; using OpcLabs.EasyOpc.DataAccess; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { // Tags for channel 1 DAItemDescriptor[] tags1 = new DAItemDescriptor[2]; tags1[0] = "Demo.Ramp"; tags1[1] = "Demo.Single"; // Tags for channel 2 DAItemDescriptor[] tags2 = new DAItemDescriptor[2]; tags2[0] = "Trends.Ramp (1 min)"; tags2[1] = "Trends.Ramp (1 s)"; // Tags for channel 3 DAItemDescriptor[] tags3 = new DAItemDescriptor[2]; tags3[0] = "Greenhouse.Humidity"; tags3[1] = "Greenhouse.RoofOpen"; EasyDAClient.SharedParameters.Topic.SlowdownWeight = 0.0f; EasyDAClient.SharedParameters.Topic.SpeedupWeight = 0.0f; Thread t1 = new Thread(() => DoWork(tags1)); t1.Name = "Thread 1"; t1.Start(); t1.Join(10000); // 10sec should be enough to let "Thread 1" finish Console.WriteLine(""); Thread t2 = new Thread(() => DoWork(tags2)); t2.Name = "Thread 2"; t2.Start(); t2.Join(10000); // 10sec should be enough to let "Thread 2" finish Console.WriteLine(""); Thread t3 = new Thread(() => DoWork(tags2)); t3.Name = "Thread 3"; t3.Start(); t3.Join(10000); // 10sec should be enough to let "Thread 3" finish Console.WriteLine(""); } static void DoWork(object data) { ServerDescriptor server = new ServerDescriptor("", "OPCLabs.KitServer.2"); DAItemDescriptor[] tags = data as DAItemDescriptor[]; EasyDAClient client = new EasyDAClient(); client.InstanceParameters.Timeouts.ReadItem = 60000; client.InstanceParameters.UpdateRates.ReadAutomatic = Timeout.Infinite; client.InstanceParameters.UpdateRates.WriteAutomatic = Timeout.Infinite; DAVtqResult[] result = client.ReadMultipleItems(server, tags); Console.WriteLine("{0} Start dispose in thread {1}", DateTime.Now, Thread.CurrentThread.Name); client.Dispose(); Console.WriteLine("{0} End dispose in thread {1}", DateTime.Now, Thread.CurrentThread.Name); } } }