Skip to content
Merged
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
9 changes: 6 additions & 3 deletions src/Proto.Actor/Mailbox/Dispatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ public SynchronousDispatcher(int throughput = DefaultThroughput)

public int Throughput { get; }

public void Schedule(Func<Task> runner) => runner().Wait();
// Surface original exceptions instead of wrapping in AggregateException
public void Schedule(Func<Task> runner) => runner().GetAwaiter().GetResult();
}

/// <summary>
Expand All @@ -80,7 +81,8 @@ public ThreadPoolDispatcher(int throughput = DefaultThroughput)
Throughput = throughput;
}

public void Schedule(Func<Task> runner) => Task.Factory.StartNew(runner, TaskCreationOptions.None);
// Run on the thread pool and intentionally ignore the returned Task
public void Schedule(Func<Task> runner) => _ = Task.Run(runner);

public int Throughput { get; set; }
}
Expand All @@ -101,7 +103,8 @@ public CurrentSynchronizationContextDispatcher(int throughput = DefaultThroughpu
}

public void Schedule(Func<Task> runner) =>
Task.Factory.StartNew(runner, CancellationToken.None, TaskCreationOptions.None, _scheduler);
// Use TaskScheduler for the current sync context and unwrap to avoid Task<Task>
_ = Task.Factory.StartNew(runner, CancellationToken.None, TaskCreationOptions.None, _scheduler).Unwrap();

public int Throughput { get; }
}
Expand Down
Loading