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


C# JobHost.CallAsync方法代码示例

本文整理汇总了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;
            }
        }
开发者ID:modulexcite,项目名称:Altostratus,代码行数:49,代码来源:Program.cs

示例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();
     }
 }
开发者ID:Enttoi,项目名称:enttoi-jobs,代码行数:12,代码来源:Program.cs

示例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();
        }
开发者ID:showlowtech,项目名称:azure-webjobs-sdk-samples,代码行数:13,代码来源:Program.cs

示例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);
 }
开发者ID:HouseOfTheFuture,项目名称:API-App,代码行数:20,代码来源:Program.cs

示例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();
 }
开发者ID:photomoose,项目名称:xmas-leds,代码行数:8,代码来源:Program.cs


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