示例#1
0
        /// <summary>
        /// Called internally by the scrobbling thread.
        /// </summary>
        private void threadedSubmit()
        {
            StreamReader reader = new StreamReader(CacheDir + cacheFileName, Encoding.Unicode);

            string[] lines = reader.ReadToEnd().Trim().Split('\n');
            reader.Close();

            foreach (string line in lines)
            {
                Lastfm.RequestParameters p = new Lastfm.RequestParameters(line);

                // Append the "[0]" to the key names
                Lastfm.RequestParameters np = new Lastfm.RequestParameters();
                foreach (string key in p.Keys)
                {
                    np[key + "[0]"] = p[key];
                }

                Connection.Scrobble(np);
            }

            // It won't get to this point unless
            // all the scrobbling was a success.
            File.Delete(CacheDir + cacheFileName);
        }
示例#2
0
        /// <summary>
        /// Called internally by the scrobbling thread.
        /// </summary>
        private void threadedSubmit()
        {
            StreamReader reader = new StreamReader(CacheDir + cacheFileName, Encoding.Unicode);

            while (!reader.EndOfStream)
            {
                Connection.Scrobble(new RequestParameters(reader.ReadLine()));
            }
            reader.Close();

            // It won't get to this point unless
            // all the scrobbling was a success.
            File.Delete(CacheDir + cacheFileName);
        }
        /// <summary>
        /// Called internally by the scrobbling thread.
        /// </summary>
        private async Task ThreadedSubmit()
        {
            try
            {
                StreamReader reader = new StreamReader(CacheDir + cacheFileName, Encoding.Unicode);
                string[]     lines  = reader.ReadToEnd().Trim().Split('\n');
                reader.Close();

                foreach (var line in lines)
                {
                    var parameters = new RequestParameters(line);
                    try
                    {
                        await Connection.Scrobble(parameters);
                    }
                    catch (ScrobblingException ex)
                    {
                        Console.WriteLine(ex);
                    }
                }

                // It won't get to this point unless all the scrobbling was a success.
                File.Delete(CacheDir + cacheFileName);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            finally
            {
                lock (locker)
                {
                    isSubmitting = false;
                }
            }
        }