diff --git a/src/System.Private.ServiceModel/src/System/ServiceModel/ClientBase.cs b/src/System.Private.ServiceModel/src/System/ServiceModel/ClientBase.cs index a83417d7bf8..56c573b0254 100644 --- a/src/System.Private.ServiceModel/src/System/ServiceModel/ClientBase.cs +++ b/src/System.Private.ServiceModel/src/System/ServiceModel/ClientBase.cs @@ -308,6 +308,7 @@ public Task OpenAsync() private async Task OpenAsync(TimeSpan timeout) { TimeoutHelper timeoutHelper = new TimeoutHelper(timeout); + await TaskHelpers.EnsureDefaultTaskScheduler(); if (!_useCachedFactory) { await GetChannelFactory().OpenHelperAsync(timeoutHelper.RemainingTime()); @@ -368,6 +369,7 @@ private async Task CloseAsync(TimeSpan timeout) } TimeoutHelper timeoutHelper = new TimeoutHelper(timeout); + await TaskHelpers.EnsureDefaultTaskScheduler(); if (_channel != null) { await InnerChannel.CloseHelperAsync(timeoutHelper.RemainingTime()); diff --git a/src/System.Private.ServiceModel/tests/Common/Infrastructure/xunit/WcfTestCase.cs b/src/System.Private.ServiceModel/tests/Common/Infrastructure/xunit/WcfTestCase.cs index 497e98ed711..c3a1c1afa30 100644 --- a/src/System.Private.ServiceModel/tests/Common/Infrastructure/xunit/WcfTestCase.cs +++ b/src/System.Private.ServiceModel/tests/Common/Infrastructure/xunit/WcfTestCase.cs @@ -51,7 +51,7 @@ public override async Task RunAsync( ConcurrentQueue events = new ConcurrentQueue(); s_testListener.EventWritten = events.Enqueue; Timer timer = null; - if (_failFastDuration != System.Threading.Timeout.InfiniteTimeSpan) + if (_failFastDuration != System.Threading.Timeout.InfiniteTimeSpan && !System.Diagnostics.Debugger.IsAttached) { timer = new Timer((s) => Environment.FailFast("Test timed out"), null,