Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ObservableTaskFactory.cs
1using System;
3using System.Linq;
4using System.Text;
5using System.Threading.Tasks;
9
11{
13 {
14 private readonly IObservableTaskTelemetry? telemetry;
15
16 public ObservableTaskFactory(IObservableTaskTelemetry? telemetry = null)
17 {
18 this.telemetry = telemetry;
19 }
20
21 public ObservableTask<TProgress> Create<TProgress>(
22 string name,
23 Func<TaskContext<TProgress>, Task> op,
24 bool autoStart = true,
25 bool useTaskRun = false,
26 params IAsyncPolicy[] policies)
27 {
29 .Named(name)
30 .AutoStart(autoStart)
31 .UseTaskRun(useTaskRun)
32 .Run(op);
33
34 if(this.telemetry is not null)
35 Builder.WithTelemetry(this.telemetry);
36
37 foreach (IAsyncPolicy Policy in policies)
38 Builder.WithPolicy(Policy);
39
40 return Builder.Build();
41 }
42 }
43}
Provides a data-binding friendly mechanism to manage and report the status of asynchronous operations...
class TaskContext< TProgress >(bool IsRefreshing, CancellationToken CancellationToken, IProgress< TProgress > Progress)
Represents the context for an asynchronous task execution.
Definition: TaskContext.cs:9