コード例 #1
0
        public static ActionBlockExecutorSettings DefaultWith(bool supportSynchronizationContext = true)
        {
            var settings = new ActionBlockExecutorSettings();

            settings.SupportSynchronizationContext = supportSynchronizationContext;
            return(settings);
        }
コード例 #2
0
ファイル: ActionBlockExecutor.cs プロジェクト: Rush/Stacks
 public ActionBlockExecutor(string name, ActionBlockExecutorSettings settings)
 {
     this.name = name;
     this.supportSynchronizationContext = settings.SupportSynchronizationContext;
     this.queue = new ActionBlock<Action>(a =>
     {
         ExecuteAction(a);
     }, new ExecutionDataflowBlockOptions
     {
         BoundedCapacity = settings.QueueBoundedCapacity,
         MaxDegreeOfParallelism = settings.MaxDegreeOfParallelism
     });
 }
コード例 #3
0
        public ActionBlockExecutor(string name, ActionBlockExecutorSettings settings)
        {
            this.name = name;
            this.supportSynchronizationContext = settings.SupportSynchronizationContext;

            if (settings.QueueBoundedCapacity <= 0)
                col = new BlockingCollection<Action>();
            else
                col = new BlockingCollection<Action>(settings.QueueBoundedCapacity);

            tcs = new TaskCompletionSource<int>();
            runner = new Thread(new ThreadStart(Run));
            runner.IsBackground = true;
            runner.Start();
        }
コード例 #4
0
        public ActionBlockExecutor(string name, ActionBlockExecutorSettings settings)
        {
            this.name = name == null ? string.Empty : name;
            this.supportSynchronizationContext = settings.SupportSynchronizationContext;
            this.queue = new ActionBlock <Action>(a =>
            {
                if (stopImmediately)
                {
                    return;
                }

                ExecuteAction(a);
            }, new ExecutionDataflowBlockOptions
            {
                BoundedCapacity        = settings.QueueBoundedCapacity,
                MaxDegreeOfParallelism = settings.MaxDegreeOfParallelism,
            });
        }
コード例 #5
0
        public ActionBlockExecutor(string name, ActionBlockExecutorSettings settings)
        {
            this.name = name == null ? string.Empty : name;
            this.supportSynchronizationContext = settings.SupportSynchronizationContext;

            if (settings.QueueBoundedCapacity <= 0)
            {
                col = new BlockingCollection <Action>();
            }
            else
            {
                col = new BlockingCollection <Action>(settings.QueueBoundedCapacity);
            }

            tcs    = new TaskCompletionSource <int>();
            runner = new Thread(new ThreadStart(Run));
            runner.IsBackground = true;
            runner.Start();
        }
コード例 #6
0
 public static ActionBlockExecutorSettings DefaultWith(bool supportSynchronizationContext = true)
 {
     var settings = new ActionBlockExecutorSettings();
     settings.SupportSynchronizationContext = supportSynchronizationContext;
     return settings;
 }