Пример #1
0
    public IAsyncTask CreateTask(TimeSpan interval, Func <Task> action)
    {
        var asyncTask = new TplAsyncTask("task", action, new ConsoleLoggerFactory(false), false)
        {
            Interval = interval
        };

        return(asyncTask);
    }
Пример #2
0
            public AsyncTaskWorker(string name, ITransport transport, IPipeline pipeline, IPipelineInvoker pipelineInvoker, int maxParallelismPerWorker, IRebusLoggerFactory rebusLoggerFactory)
            {
                _transport                 = transport;
                _pipeline                  = pipeline;
                _pipelineInvoker           = pipelineInvoker;
                _parallelOperationsManager = new ParallelOperationsManager(maxParallelismPerWorker);
                _log = rebusLoggerFactory.GetCurrentClassLogger();

                Name = name;

                _workerTask = new TplAsyncTask(name, DoWork, new ConsoleLoggerFactory(false), prettyInsignificant: true)
                {
                    Interval = TimeSpan.FromMilliseconds(1)
                };
                _log.Debug("Starting (task-based) worker {0}", Name);
                _workerTask.Start();
            }