Example #1
0
        /// <summary>
        /// Initialize a freezerCapture instance in boundingHostName:boudingPort with the specified xulPath and the parentIdentifer
        /// </summary>
        /// <param name="boundingHostName"></param>
        /// <param name="boundingPort"></param>
        /// <param name="xulPath"></param>
        /// <param name="parentLockIdentifier"></param>
        public static void SetupHost(string boundingHostName, int boundingPort, string xulPath, string parentLockIdentifier)
        {
            RunnerCoreGlobal.XulPath = xulPath;

            var baseAddress = new Uri($"net.tcp://{boundingHostName}:{boundingPort}/freezerworker");

            WaitForParentToExitAsync(parentLockIdentifier);

            using (var host = new ServiceHost(typeof(RunnerEngineHost), baseAddress))
            {
                var smb = new ServiceMetadataBehavior
                {
                    MetadataExporter = { PolicyVersion = PolicyVersion.Policy15 }
                };

                host.AddServiceEndpoint(typeof(IWorker), ServiceSettings.GetDefaultBinding(), string.Empty);

                host.Description.Behaviors.Add(smb);
                host.Open();

                Console.WriteLine();
                Console.WriteLine(@"freezercapture started");

                ThreadGuard.Instance.Block();
                host.Close();
            }
        }