private void CheckAndRequest(object sender, EventArgs e)
 {
     Debug.WriteLine("CheckAndRequest");
     while (lastChunk != fs.ChunksState.Length && fs.ChunksState.Get(lastChunk))
     {
         lastChunk++;
     }
     lock (endPointManagers) {
         int c = lastChunk;
         foreach (EndPointManager epm in endPointManagers.Values)
         {
             if (epm.ClientFileState != null && epm.AllChunksFinished)
             {
                 Dictionary <int, Chunk> chunks = new Dictionary <int, Chunk>();
                 for (; c < fs.NumberOfChunks && chunks.Count < 8; c++)
                 {
                     if (fs.ChunksState.Get(c) == false &&
                         this.requested.Get(c) == false &&
                         epm.ClientFileState.Get(c) == true)
                     {
                         int chunkPartCount, chunkSize;
                         if (c != fs.NumberOfChunks - 1)
                         {
                             chunkPartCount = Sizes.ChunkPartCount;
                             chunkSize      = Sizes.ChunkSize;
                         }
                         else
                         {
                             chunkPartCount = Sizes.LastChunkPartsCount(fs.FileDescription.FileSize);
                             chunkSize      = Sizes.LastChunkSize(fs.FileDescription.FileSize);
                         }
                         chunks.Add(c, new Chunk(c, epm, chunkPartCount, chunkSize));
                         this.requested.Set(c, true);
                     }
                 }
                 if (chunks.Count != 0)
                 {
                     epm.AssignNewChunks(chunks);
                     FileTransferCenter.ftc.ndm.RequestChunks(epm.EndPointId, this.fileId, chunks.Keys.ToArray());
                 }
             }
         }
     }
 }