コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WorkersHost" /> class.
        /// </summary>
        /// <param name="provider">The provider.</param>
        /// <param name="cancellationTokenSource">The cancellation token source.</param>
        /// <exception cref="System.ArgumentNullException">
        /// Thrown if provider or cancellation token source is null.
        /// </exception>
        public WorkersHost(IWorkersProvider provider, CancellationTokenSource cancellationTokenSource)
        {
            if (provider == null)
            {
                throw new ArgumentNullException(nameof(provider));
            }

            this.provider = provider;
            this.cancellationTokenSource = cancellationTokenSource;
        }
コード例 #2
0
ファイル: Application.cs プロジェクト: BionStt/EntLibLight
        /// <summary>
        /// The run workers host service.
        /// </summary>
        /// <param name="optionsBootstrap">
        /// The options.
        /// </param>
        /// <param name="providerBootstrap">
        /// The bootstrap.
        /// </param>
        public void RunWorkersHostService(Func <string[], WinServiceOptions> optionsBootstrap, Func <string[], IWorkersProvider> providerBootstrap)
        {
            this.RunApplication(
                delegate(string[] strings)
            {
                IWorkersProvider workersProvider = providerBootstrap(strings);
                if (workersProvider == null)
                {
                    throw new InvalidOperationException(
                        $"Unable to {nameof(RunWorkersHostService)} because invocation of {nameof(providerBootstrap)} returns null");
                }

                WinServiceOptions options = optionsBootstrap(strings);
                if (options == null)
                {
                    throw new InvalidOperationException(
                        $"Unable to {nameof(RunWorkersHostService)} because invocation of {nameof(optionsBootstrap)} returns null");
                }

                return(new Tuple <IWorkersProvider, WinServiceOptions>(workersProvider, options));
            },
                RunWorkersHost);
        }
コード例 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WorkersHost"/> class.
 /// </summary>
 /// <param name="provider">The provider.</param>
 public WorkersHost(IWorkersProvider provider)
     : this(provider, null)
 {
 }