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


C# JobHost.Start方法代码示例

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


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

示例1: JobHost

 static void JobHost()
 {
     var config = new JobHostConfiguration();
     var host = new JobHost(config);
     host.RunAndBlock();
     host.Start();
 }
开发者ID:yonglehou,项目名称:Microservices2015,代码行数:7,代码来源:Program.cs

示例2: InvokeQueueFunctionAndWaitForResult

        private void InvokeQueueFunctionAndWaitForResult(MethodInfo function, CloudQueueMessage message = null)
        {
            if (message == null)
            {
                message = new CloudQueueMessage(POCO.JsonSample);
            }

            string queueName = CreateQueueName(function, input: true);

            CloudQueueClient queueClient = StorageAccount.CloudStorageAccount.CreateCloudQueueClient();
            CloudQueue queue = queueClient.GetQueueReference(queueName);
            queue.CreateIfNotExists();
            queue.AddMessage(message);

            JobHostConfiguration hostConfiguration = new JobHostConfiguration(StorageAccount.ConnectionString)
            {
                TypeLocator = new ExplicitTypeLocator(
                    typeof(QueueArgumentsDisplayFunctions),
                    typeof(DoneNotificationFunction))
            };

            using (JobHost host = new JobHost(hostConfiguration))
            using (DoneNotificationFunction._doneEvent = new ManualResetEvent(initialState: false))
            {
                host.Start();
                DoneNotificationFunction._doneEvent.WaitOne();
                host.Stop();
            }
        }
开发者ID:farukc,项目名称:azure-webjobs-sdk-dashboard-tests,代码行数:29,代码来源:QueueArgumentsDisplayFixture.cs

示例3: Main

        static void Main()
        {
            CreateDemoData();

            JobHost host = new JobHost();
            host.Start();
        }
开发者ID:jasonnewyork,项目名称:AzureQuickStartsProjects,代码行数:7,代码来源:Program.cs

示例4: 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

示例5: 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

示例6: Main

        // Please set the following connection strings in app.config for this WebJob to run:
        // AzureWebJobsDashboard and AzureWebJobsStorage
        static void Main()
        {
            AppDomain.CurrentDomain.ProcessExit += CurrentDomainOnProcessExit;

            var jobStorageSecret = GetStorage(10);

            try
            {
                var host = new JobHost(new JobHostConfiguration(jobStorageSecret));
                // The following code ensures that the WebJob will be running continuously
                host.Start();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Failed to connect to storage --- assuming development?");
                Console.WriteLine(ex.Message);
            }

            var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
                "binaries\\selenium-server-standalone-2.47.1.jar");
            var process = new ProcessStartInfo("D:\\Program Files (x86)\\Java\\jdk1.8.0_25\\bin\\java.exe", "-Djava.net.preferIPv4Stack=true -jar " + path + " -role hub")
            {
                CreateNoWindow = true,
                UseShellExecute = false
            };

            var local = new ProcessStartInfo("java.exe", "-jar " + path)
            {
                UseShellExecute = false,
                CreateNoWindow = false
            };

            try
            {
                var proc = Process.Start(process);
                wait(proc);
            }
            catch
            {
                try
                {
                    var dunc = Process.Start(local);
                    wait(dunc);
                }
                catch (Exception e)
                {
                    throw new Exception("Failed to start selenium" + e.Message);
                }
            }
        }
开发者ID:withinboredom,项目名称:Banking-Service,代码行数:52,代码来源:Program.cs

示例7: Main

        static void Main()
        {
            CreateDemoData();

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

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

            while(true)
            {
                Thread.Sleep(500);
            }
        }
开发者ID:raycdut,项目名称:azure-webjobs-sdk-samples,代码行数:18,代码来源:Program.cs

示例8: 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

示例9: InvokeBlobFunctionAndWaitForResult

        private void InvokeBlobFunctionAndWaitForResult(
            MethodInfo function, 
            string triggerMessage = null, 
            string inputMessage = null)
        {
            if (triggerMessage ==null)
            {
                triggerMessage = "trigger-content-";
            }
            if (inputMessage ==null)
            {
                inputMessage = "input-content";
            }

            string blobPartialName = function.Name.ToLowerInvariant();

            CloudBlobClient blobClient = StorageAccount.CloudStorageAccount.CreateCloudBlobClient();
            CloudBlobContainer container = blobClient.GetContainerReference(BlobArgumentsDisplayFunctions.ContainerName);
            container.CreateIfNotExists();

            container
                .GetBlockBlobReference(blobPartialName + "-trigger")
                .UploadText(triggerMessage);
            container
                .GetBlockBlobReference(blobPartialName + "-in")
                .UploadText(inputMessage);

            JobHostConfiguration hostConfiguration = new JobHostConfiguration(StorageAccount.ConnectionString)
            {
                TypeLocator = new ExplicitTypeLocator(
                    typeof(BlobArgumentsDisplayFunctions),
                    typeof(BlobArgumentsDisplayFunctions.POCOBinder),
                    typeof(DoneNotificationFunction))
            };

            using (JobHost host = new JobHost(hostConfiguration))
            using (DoneNotificationFunction._doneEvent = new ManualResetEvent(initialState: false))
            {
                host.Start();
                DoneNotificationFunction._doneEvent.WaitOne();
                host.Stop();
            }
        }
开发者ID:farukc,项目名称:azure-webjobs-sdk-dashboard-tests,代码行数:43,代码来源:BlobArgumentsDisplayFixture.cs

示例10: Main

        static void Main(string[] vargStrings)
        {
            var configuration = new JobHostConfiguration();
            configuration.Queues.MaxPollingInterval = TimeSpan.FromSeconds(30);
            configuration.Queues.MaxDequeueCount = 10;
            configuration.Queues.BatchSize = 1;

            var 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:alpaix,项目名称:nebula,代码行数:21,代码来源:Program.cs

示例11: RunEndToEnd

        private void RunEndToEnd()
        {
            // create the initial messgage that starts the function chain
            CreateStartMessage();

            using (JobHost host = new JobHost(_hostConfiguration))
            using (DoneNotificationFunction._doneEvent = new ManualResetEvent(initialState: false))
            {
                host.Start();
                DoneNotificationFunction._doneEvent.WaitOne();
                host.Stop();
            }
        }
开发者ID:farukc,项目名称:azure-webjobs-sdk-dashboard-tests,代码行数:13,代码来源:ServiceBusArgumentsDisplayFixture.cs


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