Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class SynchronousProgress<T> : IProgress<T>
- {
- private readonly SynchronizationContext _Context;
- private readonly Action<T> _Action;
- public SynchronousProgress(Action<T> action)
- {
- _Action = action;
- _Context = SynchronizationContext.Current ?? new SynchronizationContext();
- }
- private void Callback(object state)
- {
- _Action?.Invoke((T)state);
- }
- public void Report(T value)
- {
- _Context.Send(Callback, value);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement