예제 #1
0
        public static async Task AsyncAwaitTaskPlayerExample()
        {
            var player = new AwaitTaskPlayer();
            await player.Load("folder");

            await player.Play();
        }
예제 #2
0
        //Текущий поток не блокируется
        public static void AwaitTaskPlayerExample2()
        {
            var player = new AwaitTaskPlayer();
            var task   = player.Load("folder");

            task.ContinueWith((t) => player.Play());
        }
예제 #3
0
        //Текущий поток блокируется
        public static void AwaitTaskPlayerExample()
        {
            var player = new AwaitTaskPlayer();
            var task   = player.Load("folder");

            task.Wait();
            player.Play();
        }
예제 #4
0
        public static async Task AsyncAwaitTaskPlayerExample()
        {
            var c1 = SynchronizationContext.Current;

            SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
            var player = new AwaitTaskPlayer();
            await player.Load("folder");

            await player.Play();
        }
예제 #5
0
        //Текущий поток не блокируется
        public static void AwaitTaskPlayerExample2()
        {
            var c1 = SynchronizationContext.Current;

            SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
            var player = new AwaitTaskPlayer();
            var task   = player.Load("folder");

            task.ContinueWith((t) =>
            {
                var c2 = SynchronizationContext.Current;
                player.Play();
            });
        }