本文整理汇总了C#中Microsoft.Azure.WebJobs.JobHost.Stop方法的典型用法代码示例。如果您正苦于以下问题:C# JobHost.Stop方法的具体用法?C# JobHost.Stop怎么用?C# JobHost.Stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Azure.WebJobs.JobHost
的用法示例。
在下文中一共展示了JobHost.Stop方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
}
示例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();
}
}
示例3: 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);
}
}
示例4: 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();
}
示例5: 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);
}
}
示例6: 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();
}
示例7: 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();
}
}
示例8: Main
// Please set the following connection strings in app.config for this WebJob to run:
// AzureWebJobsDashboard and AzureWebJobsStorage
static void Main()
{
var client = new KeyVault(new Uri(CloudConfigurationManager.GetSetting("KeyVault")));
var jobStorage = client.Secret.GetSecretByName("JobStorage");
var sb = client.Secret.GetSecretByName("ServiceBus");
if (jobStorage.Value != CloudConfigurationManager.GetSetting("JobStorage"))
{
jobStorage = new Secret()
{
ContentType = "String",
Name = "JobStorage",
Value = CloudConfigurationManager.GetSetting("JobStorage")
};
jobStorage = client.Secret.CreateSecret("JobStorage", jobStorage);
}
if (sb.Value != CloudConfigurationManager.GetSetting("ServiceBus"))
{
sb = new Secret()
{
ContentType = "String",
Name = "ServiceBus",
Value = CloudConfigurationManager.GetSetting("ServiceBus")
};
sb = client.Secret.CreateSecret("ServiceBus", sb);
}
var jobStorageConnString = jobStorage.Value;
var host = new JobHost(new JobHostConfiguration(jobStorageConnString));
host.Start();
Console.WriteLine("Bootstrapped");
host.Stop();
}
示例9: 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);
}
}
示例10: 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