當前位置: 首頁>>代碼示例>>C#>>正文


C# WebJobs.JobHost類代碼示例

本文整理匯總了C#中Microsoft.Azure.WebJobs.JobHost的典型用法代碼示例。如果您正苦於以下問題:C# JobHost類的具體用法?C# JobHost怎麽用?C# JobHost使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


JobHost類屬於Microsoft.Azure.WebJobs命名空間,在下文中一共展示了JobHost類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Main

        public static void Main()
        {
     //       string connectionString =
     //ConfigurationManager.ConnectionStrings["RootManageSharedAccessKey"].ConnectionString;
     //       Action<BrokeredMessage> callback = x =>
     //       {
                
     //       };
     //       var clients = new List<SubscriptionClient>();
     //       for (int i = 0; i < 5; i++)
     //       {
     //           var client = TopicClient.CreateFromConnectionString(connectionString, "signalr_topic_push_" + i);
     //           client.
     //           client.OnMessage(callback);
     //           clients.Add(client);
     //       }
     //       Console.ReadLine();
            //var ctx = GlobalHost.ConnectionManager.GetHubContext<yourhub>();
            //ctx.Clients.Client(connectionId).< your method >

            var cloudStorage = CloudStorageAccount.Parse(ConfigurationManager.ConnectionStrings["DataStorage"].ConnectionString);
            var tableClient = cloudStorage.CreateCloudTableClient();
            _tickEvents = tableClient.GetTableReference("tickevents");
            _tickEvents.CreateIfNotExists();
            var host = new JobHost();
            var cancelToken = new WebJobsShutdownWatcher().Token;
            _eventHubClient = EventHubClient.CreateFromConnectionString(ConfigurationManager.ConnectionStrings["IotHubConnection"].ConnectionString, iotHubD2cEndpoint);
            var d2CPartitions = _eventHubClient.GetRuntimeInformation().PartitionIds;
            Task.WaitAll(d2CPartitions.Select(partition => ListenForEvent(host, partition, cancelToken)).ToArray(), cancelToken);
            host.RunAndBlock();
        }
開發者ID:HouseOfTheFuture,項目名稱:API-App,代碼行數:31,代碼來源: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 host = new JobHost();
     
     // The following code ensures that the WebJob will be running continuously
     host.RunAndBlock();
 }
開發者ID:Kgabo707,項目名稱:azure-guidance,代碼行數:9,代碼來源:Program.cs

示例3: Main

        // Please set the following connection strings in app.config for this WebJob to run:
        // AzureWebJobsDashboard and AzureWebJobsStorage
        public static void Main()
        {
            try
            {
#if !DEBUG
                LogManager.Logger = new OneTimeLogger(new ProfileRepository());
#endif

                LogManager.Log("Start !");
                JobHostConfiguration config = new JobHostConfiguration();
                config.Queues.BatchSize = 1;
                var host = new JobHost(config);

                Init();
                Run();
#if DEBUG
                Console.WriteLine("Press any key to exit...");
                Console.ReadKey();
#else
                LogManager.Log("This is release !");
                // The following code ensures that the WebJob will be running continuously
                //host.RunAndBlock();
#endif
            }
            catch (Exception ex)
            {
                LogManager.Log(ex);
            }
            finally
            {
                LogManager.Log("End");
                LogManager.FlushLogger();
            }
        }
開發者ID:v-pi,項目名稱:cloud-deamon,代碼行數:36,代碼來源:Program.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.UseTimers();
     var host = new JobHost(config);
     host.RunAndBlock();
 }
開發者ID:bestwpw,項目名稱:letsencrypt-siteextension,代碼行數:9,代碼來源:Program.cs

示例5: Main

        // Please set the following connection strings in app.config for this WebJob to run:
        // AzureWebJobsDashboard and AzureWebJobsStorage
        private static void Main()
        {
            var demoMode = (ConfigurationManager.AppSettings["ticketdesk:DemoModeEnabled"] ?? "false").Equals("true", StringComparison.InvariantCultureIgnoreCase);
            var isEnabled = false;
            var interval = 2;
            using (var context = new TdPushNotificationContext())
            {
                isEnabled = !demoMode && context.TicketDeskPushNotificationSettings.IsEnabled;
                interval = context.TicketDeskPushNotificationSettings.DeliveryIntervalMinutes;
            }
            var storageConnectionString = AzureConnectionHelper.CloudConfigConnString ??
                                             AzureConnectionHelper.ConfigManagerConnString;
            var host = new JobHost(new JobHostConfiguration(storageConnectionString));
            if (isEnabled)
            {
                host.Call(typeof(Functions).GetMethod("StartNotificationScheduler"), new { interval});
                host.RunAndBlock();
            }
            else
            {
                Console.Out.WriteLine("Push notifications are disabled");
                host.RunAndBlock();//just run and block, to keep from recycling the service over and over
            }


        }
開發者ID:sadiqna,項目名稱:TicketDesk,代碼行數:28,代碼來源:Program.cs

示例6: Main

        public int Main(string[] args)
        {
            var builder = new ConfigurationBuilder();
            builder.Add(new JsonConfigurationProvider("config.json"));
            var config = builder.Build();
            var webjobsConnectionString = config["Data:AzureWebJobsStorage:ConnectionString"];
            var dbConnectionString = config["Data:DefaultConnection:ConnectionString"];
            if (string.IsNullOrWhiteSpace(webjobsConnectionString))
            {
                Console.WriteLine("The configuration value for Azure Web Jobs Connection String is missing.");
                return 10;
            }

            if (string.IsNullOrWhiteSpace(dbConnectionString))
            {
                Console.WriteLine("The configuration value for Database Connection String is missing.");
                return 10;
            }

            var jobHostConfig = new JobHostConfiguration(config["Data:AzureWebJobsStorage:ConnectionString"]);
            var host = new JobHost(jobHostConfig);
            var methodInfo = typeof(Functions).GetMethods().First();

            host.Call(methodInfo);
            return 0;
        }
開發者ID:dpiessens,項目名稱:PartsUnlimited,代碼行數:26,代碼來源:Program.cs

示例7: Main

        static void Main()
        {
            CreateDemoData();

            JobHost host = new JobHost();
            host.RunAndBlock();
        }
開發者ID:raycdut,項目名稱:azure-webjobs-sdk-samples,代碼行數:7,代碼來源:Program.cs

示例8: Main

        static void Main()
        {
            CreateDemoData();

            JobHost host = new JobHost();
            host.Start();
        }
開發者ID:jasonnewyork,項目名稱:AzureQuickStartsProjects,代碼行數:7,代碼來源:Program.cs

示例9: Main

		static void Main()
		{
			_servicesBusConnectionString = AmbientConnectionStringProvider.Instance.GetConnectionString(ConnectionStringNames.ServiceBus);
			namespaceManager = NamespaceManager.CreateFromConnectionString(_servicesBusConnectionString);

			if (!namespaceManager.QueueExists(nameof(Step1)))
			{
				namespaceManager.CreateQueue(nameof(Step1));
			}
			if (!namespaceManager.QueueExists(nameof(Step2)))
			{
				namespaceManager.CreateQueue(nameof(Step2));
			}

			JobHostConfiguration config = new JobHostConfiguration();
			config.UseServiceBus();



			var host = new JobHost(config);

			CreateStartMessage();

			host.RunAndBlock();
		}
開發者ID:Cognim,項目名稱:Azure-webjobs-and-service-bus-tryout,代碼行數:25,代碼來源:Program.cs

示例10: Main

        static void Main()
        {
            CreateDemoData();

            JobHostConfiguration configuration = new JobHostConfiguration();

            // Demonstrates the global queue processing settings that can
            // be configured
            configuration.Queues.MaxPollingInterval = TimeSpan.FromSeconds(30);
            configuration.Queues.MaxDequeueCount = 10;
            configuration.Queues.BatchSize = 16;
            configuration.Queues.NewBatchThreshold = 20;

            // Demonstrates how queue processing can be customized further
            // by defining a custom QueueProcessor Factory
            configuration.Queues.QueueProcessorFactory = new CustomQueueProcessorFactory();

            JobHost host = new JobHost(configuration);
            host.Start();

            // Stop the host if Ctrl + C/Ctrl + Break is pressed
            Console.CancelKeyPress += (sender, args) =>
            {
                host.Stop();
            };

            while(true)
            {
                Thread.Sleep(500);
            }
        }
開發者ID:showlowtech,項目名稱:azure-webjobs-sdk-samples,代碼行數:31,代碼來源:Program.cs

示例11: Main

 static void Main(string[] args)
 {
     var host = new JobHost();
     Console.WriteLine("EventHubReader has been started at " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:tt"));
     host.Call(typeof(Functions).GetMethod("ReadEventHub"));
     //host.RunAndBlock();
 }
開發者ID:iremmats,項目名稱:apim-eventhubreader,代碼行數:7,代碼來源:Program.cs

示例12: Main

        static void Main(string[] args)
        {
            var host = new JobHost();
            Console.Error.Write("An error occurred in this web job");

            host.RunAndBlock();
        }
開發者ID:codesocket,項目名稱:CodeSocketAD,代碼行數:7,代碼來源:Program.cs

示例13: Main

        static void Main(string[] args)
        {
            JobHostConfiguration config = new JobHostConfiguration();
            //config.Tracing.Trace = new ConsoleTraceWriter(TraceLevel.Verbose);
            config.UseRedis();
            
            JobHost host = new JobHost(config);
            host.Start();

            // Give subscriber chance to startup
            Task.Delay(5000).Wait();

            host.Call(typeof(Functions).GetMethod("SendSimplePubSubMessage"));
            host.Call(typeof(Functions).GetMethod("SendPubSubMessage"));
            host.Call(typeof(Functions).GetMethod("SendPubSubMessageIdChannel"));
            host.Call(typeof(Functions).GetMethod("AddSimpleCacheMessage"));
            host.Call(typeof(Functions).GetMethod("AddCacheMessage"));
            host.Call(typeof(Functions).GetMethod("AddCacheMessage"));

            Console.CancelKeyPress += (sender, e) =>
            {
                host.Stop();
            };

            while (true)
            {
                Thread.Sleep(500);
            }
        }
開發者ID:JasonHaley,項目名稱:Redis.WebJobs.Extensions,代碼行數:29,代碼來源:Program.cs

示例14: Main

        /// <summary>
        /// Set up for logging and call our web job functions as appropriate.
        /// </summary>
        public static void Main()
        {
            var env = EnvironmentDefinition.Instance;
            var timestamp = DateTime.UtcNow.ToString("yyyy-MM-dd_HH:MM");

            var logName = $"{env.Name}_report_{timestamp}";

            var host = new JobHost();
            host.Call(
                typeof(DailyReport).GetMethod("SendDailyReport"),
                new
                {
                    logName = logName,
                    log = $"container/{logName}"
                });

            // We refresh the bot caches every two hours for now. The bots will automatically
            // refresh on their own every 8 hours if the webjob fails to run for some reason.
            // It's better if we do it here so that user's don't see the latency.

            if (DateTime.UtcNow.Hour % 2 == 0)
            {
                logName = $"{env.Name}_refresh_{timestamp}";
                host.Call(
                    typeof(RefreshCaches).GetMethod("RefreshBotCaches"),
                    new
                    {
                        logName = logName,
                        log = $"container/{logName}"
                    });
            }
        }
開發者ID:CrewNerd,項目名稱:BoatTracker,代碼行數:35,代碼來源:Program.cs

示例15: Main

        public int Main(string[] args)
        {
            var builder = new ConfigurationBuilder();
            //builder.Add(new JsonConfigurationSource("config.json"));
            builder.AddJsonFile("config.json");
            var config = builder.Build();
            var webjobsConnectionString = config["Data:AzureWebJobsStorage:ConnectionString"];
            var dbConnectionString = config["Data:DefaultConnection:ConnectionString"];

            if (string.IsNullOrWhiteSpace(webjobsConnectionString))
            {
                Console.WriteLine("The configuration value for Azure Web Jobs Connection String is missing.");
                return 10;
            }

            if (string.IsNullOrWhiteSpace(dbConnectionString))
            {
                Console.WriteLine("The configuration value for Database Connection String is missing.");
                return 10;
            }

            var jobHostConfig = new JobHostConfiguration(webjobsConnectionString);
            var host = new JobHost(jobHostConfig);

            host.RunAndBlock();
            return 0;
        }
開發者ID:philljeff,項目名稱:PartsUnlimited-master,代碼行數:27,代碼來源:Program.cs


注:本文中的Microsoft.Azure.WebJobs.JobHost類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。