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


C# HostControl类代码示例

本文整理汇总了C#中HostControl的典型用法代码示例。如果您正苦于以下问题:C# HostControl类的具体用法?C# HostControl怎么用?C# HostControl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


HostControl类属于命名空间,在下文中一共展示了HostControl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Start

        public bool Start(HostControl hc)
        {
            mqtt.MqttConnect(serveur, clientid);
            mqtt = new Mqttclient_handler();
            foreach (var tokv in topicsStr.Split(';'))
            {
                string topicname = tokv.Split('=')[0];
                string topicvalue = tokv.Split('=')[1];
                mqtt.subscribe(topicvalue, 0);
                // topicNames.Add(topicvalue, topicname);
            }

            t = new Timer(WriteMessages, null, 10000, 10 * 60000);

            // Console.WriteLine("mqtt isconnected : {0}", mqtt.IsConnected);
            mqtt.OnMessageArrived += (Mqttclient_handler sender, MessPublishEventArgs e) =>
            {
                Console.WriteLine("at {0} from {1} : {2}", e.Message.Date, e.Message.Topic, e.Message.GetStringMessage());
                if (!messagesByTopic.ContainsKey(e.Message.Topic))
                    messagesByTopic.Add(e.Message.Topic, new List<MqttMessage>());
                messagesByTopic[e.Message.Topic].Add(e.Message);
                if (messagesByTopic[e.Message.Topic].Count > 20)
                {
                    SaveMessages(messagesByTopic[e.Message.Topic], e.Message.Topic, FileType.csv);
                    messagesByTopic[e.Message.Topic].Clear();
                }
            };
            return true;
         /*  do
            {
                Thread.Sleep(50);
            } while (true);*/
        }
开发者ID:simonAndre,项目名称:MQTT,代码行数:33,代码来源:mqttservice.cs

示例2: Start

        public bool Start(HostControl hostControl)
        {
            _log.Info("SampleService Starting...");

            hostControl.RequestAdditionalTime(TimeSpan.FromSeconds(10));

            Thread.Sleep(1000);

            if(_throwOnStart)
            {
                _log.Info("Throwing as requested");
                throw new InvalidOperationException("Throw on Start Requested");
            }

            ThreadPool.QueueUserWorkItem(x =>
                {
                    Thread.Sleep(3000);

                    if(_throwUnhandled)
                        throw new InvalidOperationException("Throw Unhandled In Random Thread");

                    _log.Info("Requesting stop");

                    hostControl.Stop();
                });
            _log.Info("SampleService Started");

            return true;
        }
开发者ID:CharlieBP,项目名称:Topshelf,代码行数:29,代码来源:SampleService.cs

示例3: Stop

        public bool Stop(HostControl hostControl)
        {
            if (app != null)
                app.Dispose();

            return true;
        }
开发者ID:dahlbyk,项目名称:Presentations,代码行数:7,代码来源:EmailService.cs

示例4: Start

        /// <summary>
        /// Starts the specified host control.
        /// </summary>
        /// <param name="hostControl">The host control.</param>
        /// <returns></returns>
        public virtual bool Start(HostControl hostControl)
        {
            ShutdownWatcher.Token.Register(hostControl.Stop);
            JobHost.Start();

            return true;
        }
开发者ID:bradsjm,项目名称:AprsEventHubDemo,代码行数:12,代码来源:JobHostService.cs

示例5: Stop

 public bool Stop(HostControl hostControl)
 {
     _log.Info("stop service");
     _serviceHost.Close();
     _serviceHost = null;
     return true;
 }
开发者ID:svargy,项目名称:arma3beclient,代码行数:7,代码来源:BackendRunner.cs

示例6: Start

            public bool Start(HostControl hostControl)
            {
                Log.Info("Starting Service...");

                var Config = Configuration.LoadFromFile("Jobs.xml");

                foreach (var config in Config.Jobs)
                {
                    if (!config.Enabled) continue;

                    var job = config.GenerateJob();

                    var trigger = TriggerBuilder.Create()
                        .ForJob(job)
                        .WithCronSchedule(config.CronTrigger)
                        .StartNow()
                        .Build();

                    this.scheduler.ScheduleJob(job, trigger);
                }

                this.scheduler.Start();

                return true;
            }
开发者ID:ChuckLangford,项目名称:Task-Processor,代码行数:25,代码来源:Program.cs

示例7: Stop

        public bool Stop(HostControl hostControl)
        {
            OnStopping(hostControl);

            Logger.Get(GetType())
                  .InfoFormat("Stopping {0} Service Buses for hosted service: {1}", _instances.Length, _serviceName);

            try
            {
                Parallel.ForEach(_instances, instance => instance.Dispose());

                _disposed = true;

                OnStopped(hostControl);

                Logger.Get(GetType())
                      .InfoFormat("Stopped {0} Service Buses for hosted service: {1}", _instances.Length, _serviceName);
            }
            catch (Exception ex)
            {
                OnStopFailed(hostControl, ex);
                throw;
            }

            return true;
        }
开发者ID:kinpro,项目名称:RapidTransit,代码行数:26,代码来源:ServiceBusInstanceService.cs

示例8: Start

        public bool Start(HostControl hostControl)
        {
            try
            {
                _bus = ServiceBusFactory.New(x =>
                    {
                        // just support everything by default
                        x.UseMsmq();
                        x.UseRabbitMq();
                        x.UseJsonSerializer();

                        // move this to app.config
                        x.ReceiveFrom(_controlQueueUri);
                        x.SetConcurrentConsumerLimit(_consumerLimit);

                        x.Subscribe(s =>
                            {
                                s.Consumer(() => new ScheduleMessageConsumer(_scheduler));
                                s.Consumer(() => new CancelScheduledMessageConsumer(_scheduler));
                            });
                    });

                _scheduler.JobFactory = new MassTransitJobFactory(_bus);
            }
            catch (Exception)
            {
                _scheduler.Shutdown();
                throw;
            }

            _scheduler.Start();

            return true;
        }
开发者ID:ahives,项目名称:MassTransit-Quartz,代码行数:34,代码来源:ScheduleMessageService.cs

示例9: Start

 public void Start(HostControl hostControl)
 {
     isRunning = true;
     this.hostControl = hostControl;
     channel.BeginReceive(new TimeSpan(0, 0, 0, ConfigurationSettings.PollingTimeout));
     Console.WriteLine("Service started");
 }
开发者ID:uzigula,项目名称:Styles,代码行数:7,代码来源:Consumer.cs

示例10: Start

        public bool Start(HostControl hostControl)
        {
            OnStarting(hostControl);

            Logger.Get(GetType())
                  .InfoFormat("Creating {0} Service Buses for hosted service: {1}", _instances.Length, _serviceName);

            try
            {
                Parallel.ForEach(_instances, instance => instance.Start(_transportConfigurator));

                OnStarted(hostControl);

                Logger.Get(GetType())
                      .InfoFormat("Created {0} Service Buses for hosted service: {1}", _instances.Length, _serviceName);

                return true;
            }
            catch (Exception ex)
            {
                Parallel.ForEach(_instances, instance => instance.Dispose());

                OnStartFailed(hostControl, ex);
                throw;
            }
        }
开发者ID:kinpro,项目名称:RapidTransit,代码行数:26,代码来源:ServiceBusInstanceService.cs

示例11: Start

        public bool Start(HostControl hostControl)
        {
            _log.Info("Creating bus...");

            _sagaRepository = GetSagaRepository();

            ITrackingEventWriter writer = GetTrackingEventWriter();

            _busControl = Bus.Factory.CreateUsingRabbitMq(x =>
            {
                var host = x.Host(GetHostAddress(), h =>
                {
                    h.Username(ConfigurationManager.AppSettings["RabbitMQUsername"]);
                    h.Password(ConfigurationManager.AppSettings["RabbitMQPassword"]);
                });

                x.ReceiveEndpoint(host, ConfigurationManager.AppSettings["BookingStateQueueName"], e =>
                {
                    e.StateMachineSaga(_stateMachine, _sagaRepository);
                });

                x.ReceiveEndpoint(host, ConfigurationManager.AppSettings["EventTrackingQueueName"], e =>
                {
                    e.Consumer(() => new EventTrackingConsumer(writer));
                });
            });

            _log.Info("Starting bus...");

            _busHandle = _busControl.Start();

            TaskUtil.Await(() => _busHandle.Ready);

            return true;
        }
开发者ID:rmichela,项目名称:Sample-Booking,代码行数:35,代码来源:TrackingService.cs

示例12: Start

        public bool Start(HostControl hostControl)
        {
            this.startHostControl = hostControl;

            myCallback = new Win32.ServiceControlHandlerEx(ServiceControlHandler);
            var serviceStatusHandle = Win32.RegisterServiceCtrlHandlerEx(DummyService.ServiceName,
                                                                            myCallback,
                                                                            IntPtr.Zero);
            var deviceInterface = new Win32.DEV_BROADCAST_DEVICEINTERFACE();
            int size = Marshal.SizeOf(deviceInterface);
            deviceInterface.dbcc_size = size;
            deviceInterface.dbcc_devicetype = Win32.DBT_DEVTYP_DEVICEINTERFACE;
            IntPtr buffer = default(IntPtr);
            buffer = Marshal.AllocHGlobal(size);
            Marshal.StructureToPtr(deviceInterface, buffer, true);
            deviceEventHandle = Win32.RegisterDeviceNotification(serviceStatusHandle,
                                                                    buffer,
                                                                    Win32.DEVICE_NOTIFY_SERVICE_HANDLE |
                                                                    Win32.DEVICE_NOTIFY_ALL_INTERFACE_CLASSES);
            if (deviceEventHandle == IntPtr.Zero)
            {
                // TODO handle error
            }
            return true;
        }
开发者ID:modulexcite,项目名称:TopshelfHookTestApp,代码行数:25,代码来源:DummyService.cs

示例13: Stop

 public bool Stop(HostControl hc)
 {
     mqtt.Dispose();
     t.Dispose();
     t = null;
     return true;
 }
开发者ID:simonAndre,项目名称:MQTT,代码行数:7,代码来源:mqttservice.cs

示例14: WatchForExitKey

        void WatchForExitKey(HostControl hostControl)
        {
            while (!_terminate)
            {
                Thread.Sleep(TimeSpan.FromMilliseconds(1));

                char ch;

                try
                {
                    if (!Console.KeyAvailable)
                        continue;

                    var tmp = Console.ReadKey();
                    ch = tmp.KeyChar;
                }
                catch (InvalidOperationException)
                {
                    // console input is redirected

                    var tmp = Console.In.Read();
                    if (tmp == -1)
                        continue;

                    ch = (char)tmp;
                }

                if (ch == 'q')
                {
                    Stop(hostControl);
                    Environment.Exit(0);
                }
            }
        }
开发者ID:geffzhang,项目名称:LogSearchShipper,代码行数:34,代码来源:Program.cs

示例15: Start

        public bool Start(HostControl hostControl)
        {
            if (string.IsNullOrEmpty(TestConfig.Instance.ServerUrl))
            {
                throw new Exception("Url为空 无法启动服务器");
            }

            Pioneer.WxSdk.SdkSetup.MessageTokenGetter = (dic) =>
            {

                PublicAccount pa = new PublicAccount();

                pa.EncryptionKey = TestConfig.Instance.EncryptionKey;
                pa.MessageToken = TestConfig.Instance.Token;
                pa.AppId = TestConfig.Instance.AppId;
                return pa;
            };

            SdkSetup.RegisterListener(new WxSdk.Message.DefaultMessageListener());

            StartOptions so = new StartOptions();
            so.Urls.Add(TestConfig.Instance.ServerUrl);

            innerHost = WebApp.Start(so, builder =>
            {
                builder.Use(new MessageModel().ProcessRequest);
            });

            logger.Info("监听地址:" + TestConfig.Instance.ServerUrl);

            logger.Info("启动成功");

            return true;
        }
开发者ID:findersky,项目名称:WxSdk,代码行数:34,代码来源:SdkService.cs


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