本文整理汇总了C#中Microsoft.Azure.WebJobs.JobHost.CallAsync方法的典型用法代码示例。如果您正苦于以下问题:C# JobHost.CallAsync方法的具体用法?C# JobHost.CallAsync怎么用?C# JobHost.CallAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Azure.WebJobs.JobHost
的用法示例。
在下文中一共展示了JobHost.CallAsync方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main()
{
Task task;
try
{
Database.SetInitializer<ApplicationDbContext>(
new MigrateDatabaseToLatestVersion<ApplicationDbContext,
Altostratus.DAL.Migrations.Configuration>());
Exception _lastException = null;
JobHostConfiguration jobConfig = new JobHostConfiguration();
jobConfig.DashboardConnectionString = GetAppSecret("AzureWebJobsDashboard");
jobConfig.StorageConnectionString = GetAppSecret("AzureWebJobsStorage");
var host = new JobHost(jobConfig);
// Have to wait for each function to complete before the next one starts because they use an EF
// context, and the context isn't thread-safe.
try
{
task = host.CallAsync(typeof(Functions).GetMethod("GetThreadsAsync"), new { providerName = "Twitter" });
task.Wait();
}
catch (Exception ex)
{
_lastException = ex;
}
try
{
task = host.CallAsync(typeof(Functions).GetMethod("GetThreadsAsync"), new { providerName = "StackOverflow" });
task.Wait();
}
catch (Exception ex)
{
_lastException = ex;
}
task = host.CallAsync(typeof(Functions).GetMethod("PurgeOldThreadsAsync"), new { providerName = "" });
task.Wait();
if (_lastException != null)
{
throw _lastException;
}
}
catch (Exception ex)
{
Console.Error.WriteLine("Exception: {0}\n{1}", ex.Message, ex.StackTrace);
throw;
}
}
示例2: Main
static void Main()
{
using (var host = new JobHost(new JobHostConfiguration
{
DashboardConnectionString = Configurations.StorageConnectionString,
StorageConnectionString = Configurations.StorageConnectionString
}))
{
var task = host.CallAsync(typeof(Functions).GetMethod("ProcessSensorsState"));
host.RunAndBlock();
}
}
示例3: Main
static void Main()
{
CreateDemoData();
JobHost host = new JobHost();
Task callTask = host.CallAsync(typeof(Functions).GetMethod("ManualTrigger"));
Console.WriteLine("Waiting for async operation...");
callTask.Wait();
Console.WriteLine("Task completed: " + callTask.Status);
host.RunAndBlock();
}
示例4: ListenForEvent
private static Task ListenForEvent(JobHost host, string partition, CancellationToken cancelToken)
{
return Task.Run(() =>
{
Console.WriteLine("Start listener for partition '{0}'", partition);
var eventHubReceiver = _eventHubClient.GetDefaultConsumerGroup().CreateReceiver(partition, DateTime.Now);
while (true)
{
var eventDataTask = eventHubReceiver.ReceiveAsync();
eventDataTask.Wait(cancelToken);
if (cancelToken.IsCancellationRequested)
{
cancelToken.ThrowIfCancellationRequested();
}
var eventData = eventDataTask.Result;
if (eventData == null) continue;
host.CallAsync(typeof(Program).GetMethod("ProcessMessage"), new { eventData, partition }, cancelToken);
}
}, cancelToken);
}
示例5: 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();
host.CallAsync(typeof(Functions).GetMethod("ListenForTweetsAsync"));
host.RunAndBlock();
}