private async void Button_Click_1(object sender, RoutedEventArgs e)
        {
            SynchronizationContext a = SynchronizationContext.Current;

            LogHelper.Write("sc= " + a.ToString());
            LogHelper.Write("ts= " + TaskScheduler.Current.ToString());
            var task = FooAsyncConfigureAwait();

            a = SynchronizationContext.Current;
            LogHelper.Write("sc= " + a.ToString());
            LogHelper.Write("ts= " + TaskScheduler.Current.ToString());
            await task;

            Label1.Content = "No Deadlock";
        }
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            SynchronizationContext a = SynchronizationContext.Current;

            LogHelper.Write(a.ToString());
            Label1.Content = PressMe().Result.Length;
        }
        private async Task FooAsyncConfigureAwait()
        {
            SynchronizationContext a = SynchronizationContext.Current;

            LogHelper.Write("sc= " + a.ToString());
            LogHelper.Write("ts= " + TaskScheduler.Current.ToString());
            var task = Task.Delay(10000);

            a = SynchronizationContext.Current;
            LogHelper.Write("sc= " + a.ToString());
            LogHelper.Write("ts= " + TaskScheduler.Current.ToString());
            await task.ConfigureAwait(false);

            a = SynchronizationContext.Current;
            LogHelper.Write("ts= " + TaskScheduler.Current.ToString());
            //LogHelper.Write(a.ToString());
        }
        IEnumerator PlayQueue()
        {
            CustomAlert alert = queuedAlerts.Peek();

            Console.WriteLine(unitySyncContext.ToString());
            //alert.Spawn();
            unitySyncContext.Send(SafeInvokeSpawn, alert);
            yield return(new WaitForSeconds(alert.Descriptor.AlertLifetime + 2));

            queuedAlerts.Dequeue();
            if (queuedAlerts.Count != 0)
            {
                StartCoroutine(PlayQueue());
            }
        }
Пример #5
0
 public override string ToString()
 {
     return(_syncContext.ToString());
 }