/// <summary> /// Starts file operation with separated packet header and data content /// </summary> /// <param name="in_packet">Packet determining the operation</param> /// <param name="in_callback">Callback for operation finished/timeout signaling</param> public void FileOperationStart(PacketFileOperationBase in_packet, byte[] in_data, FileOperationCallback in_callback) { string file_operation_id = in_packet.FileOperationID; lock (m_pending_file_operations) { // check if operation already pending on this file if (m_pending_file_operations.ContainsKey(file_operation_id)) { throw new Exception("File operation already pending on file ID:" + in_packet.ID); } // create pending operation information PendingFileOperationInfo operation_info = new PendingFileOperationInfo(); operation_info.Packet = in_packet; operation_info.Data = in_data; operation_info.RetryCount = 1; operation_info.SendTime = DateTime.Now; operation_info.Callback = in_callback; // store pending operation m_pending_file_operations.Add(file_operation_id, operation_info); } // send packet CommunicationManager.Default.SendPacket(in_packet, in_data); CommunicationManager.Default.PacketLogWrite("S", in_packet); }
/// <summary> /// removes file operation from the list of pending file operations /// </summary> /// <param name="in_packet"></param> public void FileOperationEnd(PacketFileOperationBase in_packet) { string file_operation_id = in_packet.FileOperationID; lock (m_pending_file_operations) { m_pending_file_operations.Remove(file_operation_id); } }