public void Add(string filePath_OID, string filePath_REAL, string object_id) { UploadOriginPhotosToStationItem _item = new UploadOriginPhotosToStationItem(); _item.FilePath_OID = filePath_OID; _item.FilePath_REAL = filePath_REAL; _item.ObjectID = object_id; lock (this) { m_items.Add(_item); } }
private void ThreadMethod(object state) { UploadOriginPhotosToStationItem _item = null; while (!m_exit) { Thread.Sleep(2500); while (true) { lock (this) { if (m_items.Count == 0) { break; } else { _item = m_items[0]; } } if (!Main.Current.RT.StationMode) { break; } try { File.Copy(_item.FilePath_OID, _item.FilePath_REAL, true); FileName _fileName = new FileName(_item.FilePath_REAL); MR_attachments_upload _uf = Main.Current.RT.REST.File_UploadFile(_fileName.Name, _item.FilePath_REAL, _item.ObjectID, true); if (_uf == null) { break; } lock (this) { m_items.Remove(_item); } File.Delete(_item.FilePath_REAL); File.Delete(_item.FilePath_OID); s_logger.Trace("UploadOriginPhotosToStation:" + _item.FilePath_REAL); } catch (Exception _e) { NLogUtility.Exception(s_logger, _e, "ThreadMethod"); break; } Thread.Sleep(1); } } }