/// <summary> /// 自动重连成功事件 /// </summary> /// <param name="lLoginID"></param> /// <param name="pchDVRIP"></param> /// <param name="nDVRPort"></param> /// <param name="dwUser"></param> private void OnlineEvent(int lLoginID, StringBuilder pchDVRIP, int nDVRPort, IntPtr dwUser) { CarPlateDevice device = _Devices.SingleOrDefault(d => d.m_nLoginID == lLoginID); if (device != null) { //自动重连成功事件后,发起订阅设备事件消息 device.m_nRealLoadPic = DHClient.DHRealLoadPicture(device.m_nLoginID, device.VideoID, EventIvs.EVENT_IVS_ALL, anaCallback, 0); device.State = 1; } }
private void ConnectAllDevices() { while (true) { foreach (CarPlateDevice device in _Devices) { //登入设备 if (device.m_nLoginID == 0 && device.VideoSource != null) { NET_DEVICEINFO deviceInfo = new NET_DEVICEINFO(); int error = 0; device.m_nLoginID = DHClient.DHLogin(device.IP, (ushort)device.VideoSource.StreamPort , device.VideoSource.UserName, device.VideoSource.Password, out deviceInfo, out error); if (device.m_nLoginID != 0) { //订阅事件 device.m_nRealLoadPic = DHClient.DHRealLoadPicture(device.m_nLoginID, device.VideoID, EventIvs.EVENT_IVS_ALL, anaCallback, 0); device.State = 1; } } } Action action = delegate() { ShowItemsOnGrid(_Devices); }; if (this.InvokeRequired) { this.Invoke(action); } else { action(); } Thread.Sleep(30 * 1000); } }