Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions dotnet/src/webdriver/BiDi/Broker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ internal sealed class Broker : IAsyncDisposable

private long _currentCommandId;

private static readonly TaskFactory _myTaskFactory = new(CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskContinuationOptions.None, TaskScheduler.Default);

private readonly Task _receivingMessageTask;
private readonly CancellationTokenSource _receiveMessagesCancellationTokenSource;

Expand All @@ -49,7 +47,7 @@ public Broker(ITransport transport, IBiDi bidi, Func<ISessionModule> sessionProv
_eventDispatcher = new EventDispatcher(sessionProvider);

_receiveMessagesCancellationTokenSource = new CancellationTokenSource();
_receivingMessageTask = _myTaskFactory.StartNew(async () => await ReceiveMessagesAsync(_receiveMessagesCancellationTokenSource.Token), TaskCreationOptions.LongRunning).Unwrap();
_receivingMessageTask = Task.Run(() => ReceiveMessagesAsync(_receiveMessagesCancellationTokenSource.Token));
}

public Task<Subscription> SubscribeAsync<TEventArgs>(string eventName, EventHandler eventHandler, SubscriptionOptions? options, JsonTypeInfo<TEventArgs> jsonTypeInfo, CancellationToken cancellationToken)
Expand Down
4 changes: 1 addition & 3 deletions dotnet/src/webdriver/BiDi/EventDispatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,10 @@ internal sealed class EventDispatcher : IAsyncDisposable

private readonly Task _eventEmitterTask;

private static readonly TaskFactory _myTaskFactory = new(CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskContinuationOptions.None, TaskScheduler.Default);

public EventDispatcher(Func<ISessionModule> sessionProvider)
{
_sessionProvider = sessionProvider;
_eventEmitterTask = _myTaskFactory.StartNew(ProcessEventsAwaiterAsync).Unwrap();
_eventEmitterTask = Task.Run(ProcessEventsAwaiterAsync);
}

public async Task<Subscription> SubscribeAsync<TEventArgs>(string eventName, EventHandler eventHandler, SubscriptionOptions? options, JsonTypeInfo<TEventArgs> jsonTypeInfo, CancellationToken cancellationToken)
Expand Down
Loading