Ejemplo n.º 1
0
 private static void NewThreadFunc(Thread ParObject)
 {
     RunFlag = false;
     while (!RunFlag)
     {
         TransferFileDataObj item = null;
         if (PCClientFilesBlocksQueue.TryPeek(out item))
         {
             if (item != null)
             {
                 if (FileTransferClient.ClientSendFileDataBlock(item))
                 {
                     TransferFileDataObj block = null;
                     if (PCClientFilesBlocksQueue.TryDequeue(out block))
                     {
                         Interlocked.Decrement(ref queueLength);
                         TransferSendFileObj fileObj = new TransferSendFileObj();
                         FilesQueue.Instance.Get(block.guId, out fileObj);
                         if (fileObj != null && block != null)
                         {
                             fileObj.SendSize = fileObj.SendSize + block.FileData.Length;
                             if (item.Order_Num == 1)
                             {
                                 fileObj.Status = SendFileStatus.StartSend;
                             }
                             else
                             {
                                 fileObj.Status = SendFileStatus.Sending;
                             }
                             if (fileObj.FileSize == fileObj.SendSize)
                             {
                                 fileObj.Status = SendFileStatus.SendEnd;
                             }
                             FilesQueue.Instance.Add(block.guId, fileObj);
                             TransferSendFileObj2 fileObj2 = new TransferSendFileObj2();
                             fileObj2.BlockNum       = item.Order_Num;
                             fileObj2.DataBlockCount = fileObj.DataBlockCount;
                             fileObj2.FileName       = fileObj.FileName;
                             fileObj2.FilePath       = fileObj.FilePath;
                             fileObj2.FileSize       = fileObj.FileSize;
                             fileObj2.ReadSize       = fileObj.ReadSize;
                             fileObj2.SendSize       = fileObj.SendSize;
                             fileObj2.serverDir      = fileObj.serverDir;
                             fileObj2.Status         = fileObj.Status;
                             FileTransferClient.UpLoadFileMsg(new UpLoadFileEventArgs(block.guId, fileObj2));
                         }
                     }
                 }
             }
         }
     }
     //RunFlag = true;
     ////Utility.Log.Log.writeLineToLog("发送线程终止000:" , "Send");
     ////Thread.Sleep(3000);
     //ParObject.Abort();
     //ParObject = null;
 }
Ejemplo n.º 2
0
 private static void NewThreadFunc()
 {
     //RunFlag = false;
     while (true)
     {
         TransferFileDataObj item = null;
         if (PCClientFilesBlocksQueue.TryPeek(out item))
         {
             if (item != null)
             {
                 if (FileTransferClient.ClientSendFileDataBlock(item))
                 {
                     TransferFileDataObj block = null;
                     if (PCClientFilesBlocksQueue.TryDequeue(out block))
                     {
                         Interlocked.Decrement(ref queueLength);
                         TransferSendFileObj fileObj = new TransferSendFileObj();
                         FilesQueue.Instance.Get(block.guId, out fileObj);
                         if (fileObj != null && block != null)
                         {
                             fileObj.SendSize = fileObj.SendSize + block.CanReadLength;
                             if (item.Order_Num == 1)
                             {
                                 fileObj.Status = SendFileStatus.StartSend;
                             }
                             else
                             {
                                 fileObj.Status = SendFileStatus.Sending;
                             }
                             if (fileObj.FileSize == fileObj.SendSize)
                             {
                                 fileObj.Status = SendFileStatus.SendEnd;
                             }
                             FilesQueue.Instance.Add(block.guId, fileObj);
                             TransferSendFileObj2 fileObj2 = new TransferSendFileObj2();
                             fileObj2.BlockNum       = item.Order_Num;
                             fileObj2.DataBlockCount = fileObj.DataBlockCount;
                             fileObj2.FileName       = fileObj.FileName;
                             fileObj2.FilePath       = fileObj.FilePath;
                             fileObj2.FileSize       = fileObj.FileSize;
                             fileObj2.ReadSize       = fileObj.ReadSize;
                             fileObj2.SendSize       = fileObj.SendSize;
                             fileObj2.serverDir      = fileObj.serverDir;
                             fileObj2.Status         = fileObj.Status;
                             FileTransferClient.UpLoadFileMsg(new UpLoadFileEventArgs(block.guId, fileObj2));
                         }
                     }
                 }
             }
         }
     }
 }