task-parallel-library

For a TPL Dataflow: How do I get my hands on all the output produced by a TransformBlock while blocking until all inputs have been processed?

会有一股神秘感。 提交于 2021-01-16 03:56:40
问题 I'm submitting a series of select statements (queries - thousands of them) to a single database synchronously and getting back one DataTable per query (Note: This program is such that it has knowledge of the DB schema it is scanning only at run time, hence the use of DataTables ). The program runs on a client machine and connects to DBs on a remote machine. It takes a long time to run so many queries. So, assuming that executing them async or in parallel will speed things up, I'm exploring

For a TPL Dataflow: How do I get my hands on all the output produced by a TransformBlock while blocking until all inputs have been processed?

一曲冷凌霜 提交于 2021-01-16 03:55:00
问题 I'm submitting a series of select statements (queries - thousands of them) to a single database synchronously and getting back one DataTable per query (Note: This program is such that it has knowledge of the DB schema it is scanning only at run time, hence the use of DataTables ). The program runs on a client machine and connects to DBs on a remote machine. It takes a long time to run so many queries. So, assuming that executing them async or in parallel will speed things up, I'm exploring

For a TPL Dataflow: How do I get my hands on all the output produced by a TransformBlock while blocking until all inputs have been processed?

徘徊边缘 提交于 2021-01-16 03:54:56
问题 I'm submitting a series of select statements (queries - thousands of them) to a single database synchronously and getting back one DataTable per query (Note: This program is such that it has knowledge of the DB schema it is scanning only at run time, hence the use of DataTables ). The program runs on a client machine and connects to DBs on a remote machine. It takes a long time to run so many queries. So, assuming that executing them async or in parallel will speed things up, I'm exploring

Enforcing one async observable at a time

旧时模样 提交于 2021-01-02 23:49:30
问题 I'm trying to integrate some TPL async into a larger Rx chain using Observable.FromAsync , like in this small example: using System; using System.Reactive.Linq; using System.Threading.Tasks; namespace rxtest { class Program { static void Main(string[] args) { MainAsync().Wait(); } static async Task MainAsync() { await Observable.Generate(new Random(), x => true, x => x, x => x.Next(250, 500)) .SelectMany((x, idx) => Observable.FromAsync(async ct => { Console.WriteLine("start: " + idx.ToString

Enforcing one async observable at a time

心已入冬 提交于 2021-01-02 23:46:29
问题 I'm trying to integrate some TPL async into a larger Rx chain using Observable.FromAsync , like in this small example: using System; using System.Reactive.Linq; using System.Threading.Tasks; namespace rxtest { class Program { static void Main(string[] args) { MainAsync().Wait(); } static async Task MainAsync() { await Observable.Generate(new Random(), x => true, x => x, x => x.Next(250, 500)) .SelectMany((x, idx) => Observable.FromAsync(async ct => { Console.WriteLine("start: " + idx.ToString

Correct pattern to dispose of cancellation token source

拈花ヽ惹草 提交于 2021-01-02 12:14:39
问题 Consider a scenario where you have some asynchronous work to be done and you can run it in a fire and forget mode. This asynchronous work is able to listen for cancellation and so you pass it a cancellation token in order to being able to cancel it. At a given moment in time we can decide to request the cancellation of the ongoing activity, by using the cancellation token source object from which we have taken the cancellation token. Because cancellation token source implements IDisposable ,

Correct pattern to dispose of cancellation token source

℡╲_俬逩灬. 提交于 2021-01-02 12:14:02
问题 Consider a scenario where you have some asynchronous work to be done and you can run it in a fire and forget mode. This asynchronous work is able to listen for cancellation and so you pass it a cancellation token in order to being able to cancel it. At a given moment in time we can decide to request the cancellation of the ongoing activity, by using the cancellation token source object from which we have taken the cancellation token. Because cancellation token source implements IDisposable ,

Correct pattern to dispose of cancellation token source

◇◆丶佛笑我妖孽 提交于 2021-01-02 12:13:03
问题 Consider a scenario where you have some asynchronous work to be done and you can run it in a fire and forget mode. This asynchronous work is able to listen for cancellation and so you pass it a cancellation token in order to being able to cancel it. At a given moment in time we can decide to request the cancellation of the ongoing activity, by using the cancellation token source object from which we have taken the cancellation token. Because cancellation token source implements IDisposable ,

Correct pattern to dispose of cancellation token source

|▌冷眼眸甩不掉的悲伤 提交于 2021-01-02 12:10:16
问题 Consider a scenario where you have some asynchronous work to be done and you can run it in a fire and forget mode. This asynchronous work is able to listen for cancellation and so you pass it a cancellation token in order to being able to cancel it. At a given moment in time we can decide to request the cancellation of the ongoing activity, by using the cancellation token source object from which we have taken the cancellation token. Because cancellation token source implements IDisposable ,

Finding out where unobservedTaskException is thrown: stacktrace is null

那年仲夏 提交于 2021-01-01 08:00:05
问题 I have a large C# appication using third party libraries and somewhere in the application a task is run which is not awaited and throws an exception. So I added an event handler to TaskScheduler.UnobservedTaskException: TaskScheduler.UnobservedTaskException += (sender, args) => { _logger.Error(args.Exception); args.SetObserved(); }; However, when this handler is executed, I get some exception with a stacktrace of null: System.AggregateException: A Task's exception(s) were not observed either