Microsoft.HockeyApp.Channel.Storage.Peek C# (CSharp) Méthode

Peek() private méthode

Reads an item from the storage. Order is Last-In-First-Out. When the Transmission is no longer needed (it was either sent or failed with a non-retriable error) it should be disposed.
private Peek ( ) : StorageTransmission
Résultat StorageTransmission
        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;
        }