Commit 2f46249d authored by Marc Gravell's avatar Marc Gravell

this may be a terrible idea

parent dc1038a9
...@@ -151,12 +151,10 @@ private void AssertOnMessage(Delegate handler) ...@@ -151,12 +151,10 @@ private void AssertOnMessage(Delegate handler)
public void OnMessage(Action<ChannelMessage> handler) public void OnMessage(Action<ChannelMessage> handler)
{ {
AssertOnMessage(handler); AssertOnMessage(handler);
using (ExecutionContext.SuppressFlow())
{
ThreadPool.QueueUserWorkItem( ThreadPool.QueueUserWorkItem(
state => ((ChannelMessageQueue)state).OnMessageSyncImpl(), this); state => ((ChannelMessageQueue)state).OnMessageSyncImpl(), this);
} }
}
private async void OnMessageSyncImpl() private async void OnMessageSyncImpl()
{ {
...@@ -184,12 +182,10 @@ private async void OnMessageSyncImpl() ...@@ -184,12 +182,10 @@ private async void OnMessageSyncImpl()
public void OnMessage(Func<ChannelMessage, Task> handler) public void OnMessage(Func<ChannelMessage, Task> handler)
{ {
AssertOnMessage(handler); AssertOnMessage(handler);
using (ExecutionContext.SuppressFlow())
{
ThreadPool.QueueUserWorkItem( ThreadPool.QueueUserWorkItem(
state => ((ChannelMessageQueue)state).OnMessageAsyncImpl(), this); state => ((ChannelMessageQueue)state).OnMessageAsyncImpl(), this);
} }
}
private async void OnMessageAsyncImpl() private async void OnMessageAsyncImpl()
{ {
......
...@@ -857,7 +857,7 @@ public static ConnectionMultiplexer Connect(string configuration, TextWriter log ...@@ -857,7 +857,7 @@ public static ConnectionMultiplexer Connect(string configuration, TextWriter log
/// <param name="log">The <see cref="TextWriter"/> to log to.</param> /// <param name="log">The <see cref="TextWriter"/> to log to.</param>
public static ConnectionMultiplexer Connect(ConfigurationOptions configuration, TextWriter log = null) public static ConnectionMultiplexer Connect(ConfigurationOptions configuration, TextWriter log = null)
{ {
using (ExecutionContext.SuppressFlow()) using (ExecutionContext.IsFlowSuppressed() ? null : (AsyncFlowControl?)ExecutionContext.SuppressFlow())
{ {
return ConnectImpl(() => CreateMultiplexer(configuration), log); return ConnectImpl(() => CreateMultiplexer(configuration), log);
} }
......
...@@ -669,7 +669,7 @@ private PhysicalConnection GetConnection(TextWriter log) ...@@ -669,7 +669,7 @@ private PhysicalConnection GetConnection(TextWriter log)
// in that case PhysicalConnection will call back to PhysicalBridge, and most of PhysicalBridge methods assumes that physical is not null; // in that case PhysicalConnection will call back to PhysicalBridge, and most of PhysicalBridge methods assumes that physical is not null;
physical = new PhysicalConnection(this); physical = new PhysicalConnection(this);
using (ExecutionContext.SuppressFlow()) using (ExecutionContext.IsFlowSuppressed() ? null : (AsyncFlowControl?)ExecutionContext.SuppressFlow())
{ {
physical.BeginConnectAsync(log); physical.BeginConnectAsync(log);
} }
......
...@@ -1496,7 +1496,7 @@ private static RawResult ReadLineTerminatedString(ResultType type, ref BufferRea ...@@ -1496,7 +1496,7 @@ private static RawResult ReadLineTerminatedString(ResultType type, ref BufferRea
internal void StartReading() internal void StartReading()
{ {
using (ExecutionContext.SuppressFlow()) using (ExecutionContext.IsFlowSuppressed() ? null : (AsyncFlowControl?)ExecutionContext.SuppressFlow())
{ {
ReadFromPipe(); ReadFromPipe();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment