internal override StorageTransmission Peek()
{
IEnumerable<FileInfo> files = this.GetFiles("*.trn");
lock (this.peekLockObj)
{
foreach (FileInfo file in files)
{
try
{
// if a file was peeked before, skip it (wait until it is disposed).
if (this.peekedTransmissions.ContainsKey(file.Name) == false && this.deletedFilesQueue.Contains(file.Name) == false)
{
// Load the transmission from disk.
StorageTransmission storageTransmissionItem = LoadTransmissionFromFileAsync(file).ConfigureAwait(false).GetAwaiter().GetResult();
// when item is disposed it should be removed from the peeked list.
storageTransmissionItem.Disposing = item => this.OnPeekedItemDisposed(file.Name);
// add the transmission to the list.
this.peekedTransmissions.Add(file.Name, file.FullName);
return storageTransmissionItem;
}
}
catch (Exception e)
{
string msg = string.Format(CultureInfo.InvariantCulture, "Failed to load an item from the storage. file: {0} Exception: {1}", file, e);
CoreEventSource.Log.LogVerbose(msg);
}
}
}
return null;
}