Example #1
0
        private void StopWorker()
        {
            if (this.ServiceHostWorker != null)
            {
                this.ServiceHostWorker.Stop();
                this.ServiceHostWorker.Dispose();
                this.ServiceHostWorker = null;
            }

            if (this.WorkerDomain != null)
            {
                AppDomain.Unload(this.WorkerDomain);
                this.WorkerDomain = null;
            }
        }
Example #2
0
        private void StartWorker()
        {
            if (this.WorkerDomain != null)
                throw new NotSupportedException("Worker domain already exists");

            if (this.ServiceHostWorker != null)
                throw new NotSupportedException("ServiceHostWorker already exists");

            string configURL = Properties.Settings.Default.SvcHostConfigURL;

            var adSetup = new AppDomainSetup();
            adSetup.ApplicationName = "ServiceHostWorker";
            this.WorkerDomain = AppDomain.CreateDomain("ServiceHostWorker", null, adSetup);
            this.ServiceHostWorker = this.WorkerDomain.CreateInstanceAndUnwrap(this.GetType().Assembly.FullName, "DKK.WindowsServiceHost.ServiceHostWorker") as ServiceHostWorker;
            this.ServiceHostWorker.ConfigURL = configURL;
            this.ServiceHostWorker.Reloader = this as IReloader;
            this.WorkerDomain.DoCallBack(() => this.ServiceHostWorker.Start());
        }