/// <summary>
        /// AgentThread の立てたスレッドに SwitchTo してから ReadTitleFromWebAsync 呼び出し。
        /// </summary>
        private static async Task RunWithContext()
        {
            // 以下の2行を入れることで、この RunAsync メソッド内の処理は必ず同じスレッドで実行されるようになる。
            var agent = new AgentThread();

            //await agent.Context.SwitchTo(); // April refresh での変更点: SwitchTo 廃止。
            SynchronizationContext.SetSynchronizationContext(agent.Context);

            await ReadTitleFromWebAsync();
        }
예제 #2
0
 public AgentSynchronizationContext(AgentThread agent)
 {
     this.agent = agent;
 }