public bool TakePhoto(Model.EESData objEESData) { Logger.WriteLogger(GlobalValues.PARKING_LOG, "Queue Id:" + objEESData.queueId + ":Entered TakePhoto"); if (objEESDaoService == null) { objEESDaoService = new EESDaoImp(); } if (objUtilityClass == null) { objUtilityClass = new UtilityClass(); } try { //string northimg =null; //string southimg = null; string imagePath = GlobalValues.IMG_DIR; string cameraConfigXmlName = "eft_config\\CameraNodes.xml"; string cuurDate = System.DateTime.Now.Date.Date.Day + "_" + System.DateTime.Now.Date.Date.Month + "_" + System.DateTime.Now.Date.Date.Year; string northimg = objEESData.queueId + "_" + objEESData.customerPkId + "_" + cuurDate + "_" + "north.jpg"; string southimg = objEESData.queueId + "_" + objEESData.customerPkId + "_" + cuurDate + "_" + "south.jpg"; string northFullPath = null; string southFullPath = null; if (objEESData.isEntry) { northFullPath = imagePath + "\\" + northimg; southFullPath = imagePath + "\\" + southimg; } else { northFullPath = imagePath + "\\" + northimg; southFullPath = imagePath + "\\" + southimg; } string northImgOPCMachine = objEESData.eesName + "_North"; string southImgOPCMachine = objEESData.eesName + "_South"; // Define a delegate that prints and returns the system tick count Func <object, bool> north = (object obj) => { // using (OpcOperationsService opcd = new OpcOperationsImp(OpcConnection.GetCamOPCServerConnection())) // { try { // opcd.WriteTagToCamOpc<bool>(northImgOPCMachine + "." + OpcTags.EES_Cam_GetCmd, true); // northimg = opcd.ReadTagFromCamOpc<string>(northImgOPCMachine + "." + OpcTags.EES_Cam_ImgPath); if (BasicConfig.GetXmlAttributeValueOfTag(cameraConfigXmlName, "Node", "Name", northImgOPCMachine, "Active").Equals("true")) { objUtilityClass.CaptureImage(BasicConfig.GetXmlAttributeValueOfTag(cameraConfigXmlName, "Node", "Name", northImgOPCMachine, "IP"), northFullPath); } //if (!string.IsNullOrEmpty(opcd.GetCamOpcError("EES" + eesNumber + "_North.Error"))) //break; } finally { //opcd.WriteTagToCamOpc<bool>(northImgOPCMachine + "." + OpcTags.EES_Cam_GetCmd, true); } // } return(true); }; // Define a delegate that prints and returns the system tick count Func <object, bool> south = (object obj) => { //using (OpcOperationsService opcd = new OpcOperationsImp(OpcConnection.GetCamOPCServerConnection())) //{ try { //opcd.WriteTagToCamOpc<bool>(southImgOPCMachine + "." + OpcTags.EES_Cam_GetCmd, true); //southimg = opcd.ReadTagFromCamOpc<string>(southImgOPCMachine + "." + OpcTags.EES_Cam_ImgPath); if (BasicConfig.GetXmlAttributeValueOfTag(cameraConfigXmlName, "Node", "Name", southImgOPCMachine, "Active").Equals("true")) { objUtilityClass.CaptureImage(BasicConfig.GetXmlAttributeValueOfTag(cameraConfigXmlName, "Node", "Name", southImgOPCMachine, "IP"), southFullPath); } //if (!string.IsNullOrEmpty(opcd.GetCamOpcError("EES" + eesNumber + "_North.Error"))) //break; } finally { //opcd.WriteTagToCamOpc<bool>(southImgOPCMachine + "." + OpcTags.EES_Cam_GetCmd, false); } // } return(true); }; Task <bool>[] tasks = new Task <bool> [2]; tasks[0] = Task <bool> .Factory.StartNew(north, 1); tasks[1] = Task <bool> .Factory.StartNew(south, 1); // Wait for all the tasks to finish. // Task.WaitAll(tasks); if (!string.IsNullOrEmpty(northimg)) { northimg = new FileInfo(northimg).Name; } if (!string.IsNullOrEmpty(southimg)) { southimg = new FileInfo(southimg).Name; } objEESDaoService.UpdatePhotoPathToCustomerTable(objEESData, southimg, northimg); } catch (Exception errMsg) { Logger.WriteLogger(GlobalValues.PARKING_LOG, "Queue Id:" + objEESData.queueId + ":Error in TakePhoto: " + errMsg.Message); } finally { } Logger.WriteLogger(GlobalValues.PARKING_LOG, "Queue Id:" + objEESData.queueId + ":Exitting TakePhoto"); return(true); }