Alxandr / SpotiFire

A project to make a SpotifyClient in C#
http://nudoc.azurewebsites.net/SpotiFire
40 stars 19 forks source link

Symbol package #25

Open EraYaN opened 11 years ago

EraYaN commented 11 years ago

Could you please include the symbol packages like they do it here: http://docs.nuget.org/docs/creating-packages/creating-and-publishing-a-symbol-package

Alxandr commented 11 years ago

Depends on how much work it is getting my build-script to do this automatically.

EraYaN commented 11 years ago

That would be awesome. BTW did you ever get this working in an WPF .NET4.5 project (GUI)? Console is fine...

EDIT: where to does it log? (NLog get's loaded but where does it store?)

Alxandr commented 11 years ago

NLog loggs depending on it's config, which can be set in code or in a nlog.conf file. You should look up nlog. Also, it works on WinForms, so I guess it should work the same in WPF, though never tried.

Alxandr commented 11 years ago

For now I've added a WPF test client (and tested that it works).

EraYaN commented 11 years ago

It seems that here Starting mainthread takes ages. Unless I make the timeout in wait short then just after time out it successfully logs in... (Not the NuGet release (I only got access violations out of that.) but one build from source (SpotiFire.dll and SpotiFire.Native.dll)

http://erayan.eu/jing/2013-04-30_0010.png

It seems to me that

[code] return Task::Factory->StartNew(gcnew Func<Session ^>(create, &$session$create::run)); (ln 250, Session.cpp) [/code]

Never actually returns something. The Session does get created and the main thread started.

EDIT: I saw how you did it in your WPF test, that way it did work. (With both build from source and from NuGet)

Alxandr commented 11 years ago

You probably have a deadlock. How/where do you await the creation of the session?

EraYaN commented 11 years ago
using System;
using SpotiFire;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace SpotiFireWPF
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        const string CLIENT_NAME = "SpotiFireTest";

        static byte[] key = new byte[] {
    /* key here */
        };
        static string cache = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Testing", CLIENT_NAME, "cache");
        static string settings = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Testing", CLIENT_NAME, "settings");
        static string userAgent = CLIENT_NAME;
        static Session session;
        public MainWindow()
        {
            InitializeComponent();
        }
        private static async Task Run()
        {
            MessageBox.Show("Creating Session.");
            session = await Spotify.CreateSession(key, cache, settings, userAgent);

            Error err = await session.Login("username", "password", false); // search playlists, play music etc

        }
        private static async Task RunLogOut()
        {
            await session.Logout();
        }

        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (session != null)
                RunLogOut().Wait();
        }

        private void button_Click(object sender, RoutedEventArgs e)
        {
            if (Run().Wait(40000)) //returned false
            {
                label.Content = "Done.";
            }
            else
            {
                label.Content = "Failed.";
                MessageBox.Show(Spotify.Task.ToString()); //nothing special
            }
        }
    }
}

With a button called button and a label called label.

Alxandr commented 11 years ago

Yeah, you make a deadlock by calling "Run.Wait".

EraYaN commented 11 years ago

So Run() should do it?

Alxandr commented 11 years ago

Await run

Alxandr commented 11 years ago

Anyone know how I can validate that the symbolsources-packages I generate atm is somewhat ... reasonable?