internal Group(DAServer server, int clientId, int serverId, string name, int updateRate, IOPCItemMgt @group)
        {
            this.server = server;
            ClientId    = clientId;
            ServerId    = serverId;
            Name        = name;
            this.@group = @group;
            UpdateRate  = updateRate;

            syncIO          = (IOPCSyncIO)@group;
            groupManagement = (IOPCGroupStateMgt)@group;
            try
            {
                asyncIO = (IOPCAsyncIO2)@group;
            }
            catch (InvalidCastException)
            {
            }
            try
            {
                connectionPointContainer = (IConnectionPointContainer)@group;
            }
            catch (InvalidCastException)
            {
            }
        }
		public void Connect()
		{
			if(serverThread != null)
				return;

			Owner.Context.IsBusy = true;
			serverThread = new WorkerThread("Server " + Name);

		    DoAsync((task, args) =>
		    {
		        server = new DAServer(Id);
		    },
            (task, args) =>
            {
                Owner.Context.IsBusy = false;

                if (args.Error != null)
                {
                    Owner.Context.Log.TraceData(TraceEventType.Error, 0, args.Error);

                    Disconnect();
                }
                else
                {
                    Icon = "/Images/ServerOn.png";
                }

                CommandList.ForEach(command => command.RiseCanExecuteChanged());
            });

            /*
		    serverThread.Post(new WorkerThread.Task
		    {
                Do = (task, args) =>
                {
                    var ip = server.GetItemProperties();

                    var a = server.GetAddressSpaceBrowser();
                    var @enum = a.GetItemIds(BrowseType.Flat, string.Empty, 0, 0).ToList();
                    var iid = a.GetItemId(@enum[5]);

                    var ipi = ip.QueryAvailableProperties(@enum[5]);
                    var ipv = ip.GetItemProperties(@enum[5], new[] { ipi[0].Id, ipi[2].Id });

                    var g = server.AddGroup(1, "test", true, 1000, 0);
                    var res = g.AddItems(new[]
                    {
                        new Item
                        {
                            Active = true,
                            ClientId = 1,
                            ItemId = iid,
                            RequestedDataType = (VarEnum)Convert.ToInt32(ipv[0].Value)
                        },
                        new Item
                        {
                            Active = true,
                            ClientId = 1,
                            ItemId = iid,
                            RequestedDataType = (VarEnum)Convert.ToInt32(ipv[0].Value)
                        }
                    });

                    var val = g.SyncReadItems(DataSource.Device, new[] { res[0].ServerId, res[1].ServerId });
                    g.Dispose();
                },
		    });
             * */
        }
		internal Group(DAServer server, int clientId, int serverId, string name, int updateRate, IOPCItemMgt @group)
		{
			this.server = server;
			ClientId = clientId;
			ServerId = serverId;
			Name = name;
			this.@group = @group;
			UpdateRate = updateRate;

			syncIO = (IOPCSyncIO) @group;
			groupManagement = (IOPCGroupStateMgt) @group;
			try
			{
				asyncIO = (IOPCAsyncIO2) @group;				
			}
			catch (InvalidCastException)
			{				
			}
			try
			{
				connectionPointContainer = (IConnectionPointContainer) @group;				
			}
			catch (InvalidCastException)
			{				
			}
		}