public static void Main() { // string connectionString = //ConfigurationManager.ConnectionStrings["RootManageSharedAccessKey"].ConnectionString; // Action<BrokeredMessage> callback = x => // { // }; // var clients = new List<SubscriptionClient>(); // for (int i = 0; i < 5; i++) // { // var client = TopicClient.CreateFromConnectionString(connectionString, "signalr_topic_push_" + i); // client. // client.OnMessage(callback); // clients.Add(client); // } // Console.ReadLine(); //var ctx = GlobalHost.ConnectionManager.GetHubContext<yourhub>(); //ctx.Clients.Client(connectionId).< your method > var cloudStorage = CloudStorageAccount.Parse(ConfigurationManager.ConnectionStrings["DataStorage"].ConnectionString); var tableClient = cloudStorage.CreateCloudTableClient(); _tickEvents = tableClient.GetTableReference("tickevents"); _tickEvents.CreateIfNotExists(); var host = new JobHost(); var cancelToken = new WebJobsShutdownWatcher().Token; _eventHubClient = EventHubClient.CreateFromConnectionString(ConfigurationManager.ConnectionStrings["IotHubConnection"].ConnectionString, iotHubD2cEndpoint); var d2CPartitions = _eventHubClient.GetRuntimeInformation().PartitionIds; Task.WaitAll(d2CPartitions.Select(partition => ListenForEvent(host, partition, cancelToken)).ToArray(), cancelToken); host.RunAndBlock(); }
/// <summary> /// Initializes a new instance of the <see cref="JobHost"/> class using the configuration provided. /// </summary> /// <param name="configuration">The job host configuration.</param> public JobHost(JobHostConfiguration configuration) { if (configuration == null) { throw new ArgumentNullException("configuration"); } _config = configuration; _shutdownTokenSource = new CancellationTokenSource(); _shutdownWatcher = WebJobsShutdownWatcher.Create(_shutdownTokenSource); _stoppingTokenSource = CancellationTokenSource.CreateLinkedTokenSource(_shutdownTokenSource.Token); }
internal static WebJobsShutdownWatcher Create(CancellationTokenSource cancellationTokenSource) { WebJobsShutdownWatcher watcher = new WebJobsShutdownWatcher(cancellationTokenSource, ownsCancellationTokenSource: false); if (watcher._watcher == null) { watcher.Dispose(); return(null); } return(watcher); }
/// <summary> /// Initializes a new instance of the <see cref="JobHost"/> class using the configuration provided. /// </summary> /// <param name="configuration">The job host configuration.</param> public JobHost(IOptions <JobHostOptions> options, IJobHostContextFactory jobHostContextFactory) { if (options == null) { throw new ArgumentNullException(nameof(options)); } _options = options.Value; _jobHostContextFactory = jobHostContextFactory; _shutdownTokenSource = new CancellationTokenSource(); _shutdownWatcher = WebJobsShutdownWatcher.Create(_shutdownTokenSource); _stoppingTokenSource = CancellationTokenSource.CreateLinkedTokenSource(_shutdownTokenSource.Token); }
/// <summary> /// Initializes a new instance of the <see cref="JobHost"/> class using the service provider provided. /// </summary> /// <param name="serviceProvider">The service provider.</param> internal JobHost(IServiceProvider serviceProvider) { if (serviceProvider == null) { throw new ArgumentNullException("serviceProvider"); } _contextFactory = serviceProvider.GetJobHostContextFactory(); if (_contextFactory == null) { throw new InvalidOperationException("The IJobHostContextFactory service must not be null."); } _shutdownTokenSource = new CancellationTokenSource(); _shutdownWatcher = WebJobsShutdownWatcher.Create(_shutdownTokenSource); _stoppingTokenSource = CancellationTokenSource.CreateLinkedTokenSource(_shutdownTokenSource.Token); }
internal static WebJobsShutdownWatcher Create(CancellationTokenSource cancellationTokenSource) { WebJobsShutdownWatcher watcher = new WebJobsShutdownWatcher(cancellationTokenSource, ownsCancellationTokenSource: false); if (watcher._watcher == null) { watcher.Dispose(); return null; } return watcher; }