当前位置: 首页>>代码示例>>C#>>正文


C# JobHostConfiguration.UseTimers方法代码示例

本文整理汇总了C#中JobHostConfiguration.UseTimers方法的典型用法代码示例。如果您正苦于以下问题:C# JobHostConfiguration.UseTimers方法的具体用法?C# JobHostConfiguration.UseTimers怎么用?C# JobHostConfiguration.UseTimers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JobHostConfiguration的用法示例。


在下文中一共展示了JobHostConfiguration.UseTimers方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

 // Please set the following connection strings in app.config for this WebJob to run:
 // AzureWebJobsDashboard and AzureWebJobsStorage
 static void Main()
 {
     var config = new JobHostConfiguration();
     config.UseTimers();
     var host = new JobHost(config);
     host.RunAndBlock();
 }
开发者ID:bestwpw,项目名称:letsencrypt-siteextension,代码行数:9,代码来源:Program.cs

示例2: Main

        // Please set the following connection strings in app.config for this WebJob to run:
        // AzureWebJobsDashboard and AzureWebJobsStorage
        static void Main()
        {
            var config = new JobHostConfiguration();
            config.UseTimers();

            var host = new JobHost(config);
            // The following code ensures that the WebJob will be running continuously
            host.RunAndBlock();
        }
开发者ID:christopheranderson,项目名称:feedbackengine,代码行数:11,代码来源:Program.cs

示例3: Generate_EndToEnd

        public async Task Generate_EndToEnd()
        {
            // construct our TimerTrigger attribute ([TimerTrigger("00:00:02", RunOnStartup = true)])
            Collection<ParameterDescriptor> parameters = new Collection<ParameterDescriptor>();
            ParameterDescriptor parameter = new ParameterDescriptor("timerInfo", typeof(TimerInfo));
            ConstructorInfo ctorInfo = typeof(TimerTriggerAttribute).GetConstructor(new Type[] { typeof(string) });
            PropertyInfo runOnStartupProperty = typeof(TimerTriggerAttribute).GetProperty("RunOnStartup");
            CustomAttributeBuilder attributeBuilder = new CustomAttributeBuilder(
                ctorInfo,
                new object[] { "00:00:02" },
                new PropertyInfo[] { runOnStartupProperty },
                new object[] { true });
            parameter.CustomAttributes.Add(attributeBuilder);
            parameters.Add(parameter);

            // create the FunctionDefinition
            FunctionMetadata metadata = new FunctionMetadata();
            TestInvoker invoker = new TestInvoker();
            FunctionDescriptor function = new FunctionDescriptor("TimerFunction", invoker, metadata, parameters);
            Collection<FunctionDescriptor> functions = new Collection<FunctionDescriptor>();
            functions.Add(function);

            // Get the Type Attributes (in this case, a TimeoutAttribute)
            ScriptHostConfiguration scriptConfig = new ScriptHostConfiguration();
            scriptConfig.FunctionTimeout = TimeSpan.FromMinutes(5);
            Collection<CustomAttributeBuilder> typeAttributes = ScriptHost.CreateTypeAttributes(scriptConfig);

            // generate the Type
            Type functionType = FunctionGenerator.Generate("TestScriptHost", "TestFunctions", typeAttributes, functions);

            // verify the generated function
            MethodInfo method = functionType.GetMethod("TimerFunction");
            TimeoutAttribute timeoutAttribute = (TimeoutAttribute)functionType.GetCustomAttributes().Single();
            Assert.Equal(TimeSpan.FromMinutes(5), timeoutAttribute.Timeout);
            Assert.True(timeoutAttribute.ThrowOnTimeout);
            Assert.True(timeoutAttribute.TimeoutWhileDebugging);
            ParameterInfo triggerParameter = method.GetParameters()[0];
            TimerTriggerAttribute triggerAttribute = triggerParameter.GetCustomAttribute<TimerTriggerAttribute>();
            Assert.NotNull(triggerAttribute);

            // start the JobHost which will start running the timer function
            JobHostConfiguration config = new JobHostConfiguration()
            {
                TypeLocator = new TypeLocator(functionType)
            };
            config.UseTimers();
            JobHost host = new JobHost(config);

            await host.StartAsync();
            await Task.Delay(3000);
            await host.StopAsync();

            // verify our custom invoker was called
            Assert.True(invoker.InvokeCount >= 2);
        }
开发者ID:Azure,项目名称:azure-webjobs-sdk-script,代码行数:55,代码来源:FunctionGeneratorEndToEndTests.cs

示例4: Main

        // Please set the following connection strings in app.config for this WebJob to run:
        // AzureWebJobsDashboard and AzureWebJobsStorage
        static void Main()
        {
            var config = new JobHostConfiguration();
            config.UseWebHooks();
            config.UseTimers();
            config.UseNotificationHubs(new NotificationHubConfiguration { HubName = "pbjobs" });

            var host = new JobHost(config);
            // The following code ensures that the WebJob will be running continuously
            host.RunAndBlock();
        }
开发者ID:paulbatum,项目名称:WebJobsHack,代码行数:13,代码来源:Program.cs

示例5: Main

        public static void Main(string[] args)
        {
            JobHostConfiguration config = new JobHostConfiguration();

            config.Tracing.ConsoleLevel = TraceLevel.Verbose;

            // Set to a short polling interval to facilitate local
            // debugging. You wouldn't want to run prod this way.
            config.Queues.MaxPollingInterval = TimeSpan.FromSeconds(2);

            FilesConfiguration filesConfig = new FilesConfiguration();
            if (string.IsNullOrEmpty(filesConfig.RootPath))
            {
                // when running locally, set this to a valid directory
                filesConfig.RootPath = @"c:\temp\files";
            }
            EnsureSampleDirectoriesExist(filesConfig.RootPath);

            config.UseFiles(filesConfig);
            config.UseTimers();
            config.UseSample();
            config.UseCore();
            var sendGridConfiguration = new SendGridConfiguration()
            {
                ToAddress = "[email protected]",
                FromAddress = new MailAddress("[email protected]", "WebJobs Extensions Samples")
            };
            config.UseSendGrid(sendGridConfiguration);

            ConfigureTraceMonitor(config, sendGridConfiguration);

            WebHooksConfiguration webHooksConfig = new WebHooksConfiguration();
            webHooksConfig.UseReceiver<GitHubWebHookReceiver>();
            config.UseWebHooks(webHooksConfig);

            JobHost host = new JobHost(config);

            host.Call(typeof(MiscellaneousSamples).GetMethod("ExecutionContext"));
            host.Call(typeof(FileSamples).GetMethod("ReadWrite"));
            host.Call(typeof(SampleSamples).GetMethod("Sample_BindToStream"));
            host.Call(typeof(SampleSamples).GetMethod("Sample_BindToString"));
            host.Call(typeof(TableSamples).GetMethod("CustomBinding"));

            // When running in Azure Web Apps, a JobHost will gracefully shut itself
            // down, ensuring that all listeners are stopped, etc. For this sample,
            // we want to ensure that same behavior when the console app window is
            // closed. This ensures that Singleton locks that are taken are released
            // immediately, etc.
            ShutdownHandler.Register(() => { host.Stop(); });

            host.RunAndBlock();
        }
开发者ID:wondenge,项目名称:azure-webjobs-sdk-extensions,代码行数:52,代码来源:Program.cs

示例6: Main

 static void Main()
 {
     var config = new JobHostConfiguration();
     var serviceBusConfig = new ServiceBusConfiguration()
     {
         ConnectionString = AmbientConnectionStringProvider
             .Instance
             .GetConnectionString(ConnectionStringNames.ServiceBus)
     };
     config.UseServiceBus(serviceBusConfig);
     config.UseTimers();
     var host = new JobHost(config);
     host.RunAndBlock();
 }
开发者ID:michaellperry,项目名称:Commuter,代码行数:14,代码来源:Program.cs

示例7: Main

        private static void Main()
        {
            var container = new StandardKernel();

            var token = ConfigurationManager.AppSettings["TOKEN"];
            var account = ConfigurationManager.AppSettings["ACCOUNT_EUR_USD"].SafeParseInt().GetValueOrDefault();

            var adapter = new OandaAdapter("https://api-fxpractice.oanda.com/v1/",
              "https://api-fxpractice.oanda.com/v1/",
              "https://stream-fxpractice.oanda.com/v1/",
              "https://stream-fxpractice.oanda.com/v1/",
              "https://api-fxpractice.oanda.com/labs/v1/",
              token);

            container.Bind<Cobra>()
                .ToConstant(new Cobra(new Adx(14),
                    new Ema(12),
                    new Ema(12),
                    new Sma(72),
                    new Sma(72),
                    new SimpleDateProvider(),
                    "EUR_USD",
                    15,
                    adapter,
                    adapter,
                    account))
                .InSingletonScope();

            container.Bind<IRateProvider>()
                .ToConstant(adapter)
                .InSingletonScope();

            var test = container.TryGet<Cobra>();

            if (test == null)
            {
                throw new Exception("Unable to build Forex System");
            }

            var config = new JobHostConfiguration
            {
                JobActivator = new MyActivator(container)
            };
            config.Tracing.ConsoleLevel = TraceLevel.Info;
            config.UseTimers();

            var host = new JobHost(config);
            host.RunAndBlock();
        }
开发者ID:emardini,项目名称:TechnicalIndicators,代码行数:49,代码来源:Program.cs

示例8: Main

        private static void Main()
        {
            var config = new JobHostConfiguration();

            config.Tracing.ConsoleLevel = TraceLevel.Info;
            config.DashboardConnectionString = CloudConfigurationManager.GetSetting("AzureWebJobsDashboard");
            config.StorageConnectionString = CloudConfigurationManager.GetSetting("AzureWebJobsStorage");

            config.UseTimers();

            var host = new JobHost(config);

           
            host.RunAndBlock();
        }
开发者ID:NemeStats,项目名称:NemeStats,代码行数:15,代码来源:Program.cs

示例9: Main

        // Please set the following connection strings in app.config for this WebJob to run:
        // AzureWebJobsDashboard and AzureWebJobsStorage
        static void Main()
        {
            JobHostConfiguration config = new JobHostConfiguration();
            config.Tracing.ConsoleLevel = System.Diagnostics.TraceLevel.Verbose;

            config.UseFiles();
            config.UseTimers();

            WebHooksConfiguration webhooksConfiguration = new WebHooksConfiguration();

            config.UseWebHooks(webhooksConfiguration);

            var host = new JobHost(config);
            // The following code ensures that the WebJob will be running continuously
            host.RunAndBlock();
        }
开发者ID:christopheranderson,项目名称:webjobs-logicapps-slackbot,代码行数:18,代码来源:Program.cs

示例10: Main

        // Be sure to add your storage account connection strings in the App.config when running locally
        // Don't check in your conection strings to Git, though
        static void Main()
        {
            // This is the config object we pass to the JobHost
            JobHostConfiguration config = new JobHostConfiguration();

            // Have our Continuous Job host log all our traces up to Verbose
            config.Tracing.ConsoleLevel = System.Diagnostics.TraceLevel.Verbose;

            // Turn on Timer Triggers
            config.UseTimers();

            // Initialize host with config
            var host = new JobHost(config);

            // The following code ensures that the WebJob will be running continuously
            host.RunAndBlock();
        }
开发者ID:Azure,项目名称:azure-webjobs-quickstart,代码行数:19,代码来源:Program.cs

示例11: Main

        public static void Main(string[] args)
        {
            JobHostConfiguration config = new JobHostConfiguration();

            config.Tracing.ConsoleLevel = TraceLevel.Verbose;

            // Set to a short polling interval to facilitate local
            // debugging. You wouldn't want to run prod this way.
            config.Queues.MaxPollingInterval = TimeSpan.FromSeconds(2);

            FilesConfiguration filesConfig = new FilesConfiguration();
            if (string.IsNullOrEmpty(filesConfig.RootPath))
            {
                // when running locally, set this to a valid directory
                filesConfig.RootPath = @"c:\temp\files";
            }
            EnsureSampleDirectoriesExist(filesConfig.RootPath);
            config.UseFiles(filesConfig);

            config.UseTimers();
            config.UseSample();
            config.UseCore();
            var sendGridConfiguration = new SendGridConfiguration()
            {
                ToAddress = "[email protected]",
                FromAddress = new MailAddress("[email protected]", "WebJobs Extensions Samples")
            };
            config.UseSendGrid(sendGridConfiguration);

            ConfigureTraceMonitor(config, sendGridConfiguration);

            WebHooksConfiguration webHooksConfig = new WebHooksConfiguration();
            webHooksConfig.UseReceiver<GitHubWebHookReceiver>();
            config.UseWebHooks(webHooksConfig);

            JobHost host = new JobHost(config);

            host.Call(typeof(MiscellaneousSamples).GetMethod("ExecutionContext"));
            host.Call(typeof(FileSamples).GetMethod("ReadWrite"));
            host.Call(typeof(SampleSamples).GetMethod("Sample_BindToStream"));
            host.Call(typeof(SampleSamples).GetMethod("Sample_BindToString"));
            host.Call(typeof(TableSamples).GetMethod("CustomBinding"));

            host.RunAndBlock();
        }
开发者ID:brendankowitz,项目名称:azure-webjobs-sdk-extensions,代码行数:45,代码来源:Program.cs

示例12: RunTimerJobTest

        private async Task RunTimerJobTest(Type jobClassType, Func<bool> condition)
        {
            ExplicitTypeLocator locator = new ExplicitTypeLocator(jobClassType);
            JobHostConfiguration config = new JobHostConfiguration
            {
                TypeLocator = locator
            };
            config.UseTimers();
            JobHost host = new JobHost(config);

            host.Start();

            await TestHelpers.Await(() =>
            {
                return condition();
            });

            host.Stop();
        }
开发者ID:oaastest,项目名称:azure-webjobs-sdk-extensions,代码行数:19,代码来源:TimerTriggerEndToEndTests.cs

示例13: Main

        public static void Main(string[] args)
        {
            var builder = new ConfigurationBuilder()
                .SetBasePath(Directory.GetCurrentDirectory())
                .AddJsonFile("appSettings.json")
                .AddInMemoryCollection()
                .AddEnvironmentVariables();//appsettings.json will be overridden with azure web appsettings

            var configuration = builder.Build();
            KeyVaultHelper kv = new KeyVaultHelper(configuration);
            KeyVaultHelper.GetCert(configuration);
            kv.GetKeyVaultSecretsCerticate();
            var azureStorageConnectionString = configuration["General:CloudStorageConnectionString"];
            JobHostConfiguration config = new JobHostConfiguration(azureStorageConnectionString);
            config.UseTimers();
            
            var host = new JobHost(config);            
            host.RunAndBlock();
        }
开发者ID:Microsoft,项目名称:mattercenter,代码行数:19,代码来源:Program.cs

示例14: Main

        public static void Main(string[] args)
        {
            JobHostConfiguration config = new JobHostConfiguration();
            FilesConfiguration filesConfig = new FilesConfiguration();

            // See https://github.com/Azure/azure-webjobs-sdk/wiki/Running-Locally for details
            // on how to set up your local environment
            if (config.IsDevelopment)
            {
                config.UseDevelopmentSettings();
                filesConfig.RootPath = @"c:\temp\files";
            }

            config.UseFiles(filesConfig);
            config.UseTimers();
            config.UseSample();
            config.UseCore();
            var sendGridConfiguration = new SendGridConfiguration()
            {
                ToAddress = "[email protected]",
                FromAddress = new MailAddress("[email protected]", "WebJobs Extensions Samples")
            };
            config.UseSendGrid(sendGridConfiguration);

            ConfigureTraceMonitor(config, sendGridConfiguration);
            
            EnsureSampleDirectoriesExist(filesConfig.RootPath);

            WebHooksConfiguration webHooksConfig = new WebHooksConfiguration();
            webHooksConfig.UseReceiver<GitHubWebHookReceiver>();
            config.UseWebHooks(webHooksConfig);

            JobHost host = new JobHost(config);

            host.Call(typeof(MiscellaneousSamples).GetMethod("ExecutionContext"));
            host.Call(typeof(FileSamples).GetMethod("ReadWrite"));
            host.Call(typeof(SampleSamples).GetMethod("Sample_BindToStream"));
            host.Call(typeof(SampleSamples).GetMethod("Sample_BindToString"));
            host.Call(typeof(TableSamples).GetMethod("CustomBinding"));

            host.RunAndBlock();
        }
开发者ID:paulbatum,项目名称:azure-webjobs-sdk-extensions,代码行数:42,代码来源:Program.cs

示例15: Main

		public static void Main(string[] args)
		{
			var builder = new ConfigurationBuilder()
				.AddJsonFile("appsettings.json")
				.AddEnvironmentVariables();

			Configuration = builder.Build();
			var container = new ServiceContainer();

			JobHostConfiguration config = new JobHostConfiguration
			{
				StorageConnectionString = Configuration["AppSettings:StorageConnectionString"],
				DashboardConnectionString = Configuration["AppSettings:StorageConnectionString"],
				JobActivator = new JobActivator(container),
				NameResolver = new NameResolver(Configuration)
			};
			config.UseTimers();

			var host = new JobHost(config);
			host.RunAndBlock();
		}
开发者ID:aquiladev,项目名称:heromon,代码行数:21,代码来源:Program.cs


注:本文中的JobHostConfiguration.UseTimers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。