本文整理汇总了C#中JobHost.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# JobHost.Dispose方法的具体用法?C# JobHost.Dispose怎么用?C# JobHost.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JobHost
的用法示例。
在下文中一共展示了JobHost.Dispose方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IndexingExceptions_CanBeHandledByTraceWriter
public void IndexingExceptions_CanBeHandledByTraceWriter()
{
JobHostConfiguration config = new JobHostConfiguration();
TestTraceWriter traceWriter = new TestTraceWriter(TraceLevel.Verbose);
config.Tracing.Tracers.Add(traceWriter);
config.TypeLocator = new FakeTypeLocator(typeof(BindingErrorsProgram));
FunctionErrorTraceWriter errorTraceWriter = new FunctionErrorTraceWriter(TraceLevel.Error);
config.Tracing.Tracers.Add(errorTraceWriter);
JobHost host = new JobHost(config);
host.Start();
// verify the handled binding error
FunctionIndexingException fex = errorTraceWriter.Errors.SingleOrDefault() as FunctionIndexingException;
Assert.True(fex.Handled);
Assert.Equal("BindingErrorsProgram.Invalid", fex.MethodName);
// verify that the binding error was logged
Assert.Equal(5, traceWriter.Traces.Count);
TraceEvent traceEvent = traceWriter.Traces[0];
Assert.Equal("Error indexing method 'BindingErrorsProgram.Invalid'", traceEvent.Message);
Assert.Same(fex, traceEvent.Exception);
Assert.Equal("Invalid container name: invalid$=+1", traceEvent.Exception.InnerException.Message);
// verify that the valid function was still indexed
traceEvent = traceWriter.Traces[1];
Assert.True(traceEvent.Message.Contains("Found the following functions"));
Assert.True(traceEvent.Message.Contains("BindingErrorsProgram.Valid"));
// verify that the job host was started successfully
traceEvent = traceWriter.Traces[4];
Assert.Equal("Job host started", traceEvent.Message);
host.Stop();
host.Dispose();
}
示例2: MultipleAccountTest
public async Task MultipleAccountTest()
{
try
{
TestTraceWriter trace = new TestTraceWriter(TraceLevel.Info);
_serviceBusConfig = new ServiceBusConfiguration();
_serviceBusConfig.MessagingProvider = new CustomMessagingProvider(_serviceBusConfig, trace);
JobHostConfiguration config = new JobHostConfiguration()
{
NameResolver = _nameResolver,
TypeLocator = new FakeTypeLocator(typeof(ServiceBusTestJobs))
};
config.Tracing.Tracers.Add(trace);
config.UseServiceBus(_serviceBusConfig);
JobHost host = new JobHost(config);
string queueName = ResolveName(StartQueueName);
string queuePrefix = queueName.Replace("-queue-start", "");
string firstTopicName = string.Format("{0}-topic/Subscriptions/{0}-queue-topic-1", queuePrefix);
WriteQueueMessage(_secondaryNamespaceManager, _secondaryConnectionString, queueName, "Test");
_topicSubscriptionCalled1 = new ManualResetEvent(initialState: false);
await host.StartAsync();
_topicSubscriptionCalled1.WaitOne(SBTimeout);
// ensure all logs have had a chance to flush
await Task.Delay(3000);
// Wait for the host to terminate
await host.StopAsync();
host.Dispose();
Assert.Equal("Test-topic-1", _resultMessage1);
}
finally
{
Cleanup();
}
}