public void Dispose() {
            if (_endpoint != null) {
                _endpoint.Dispose();
                _endpoint = null;
            }

            if (_firefox_process != null) {
                if (!_firefox_process.HasExited) {
                    _firefox_process.Kill();
                    _firefox_process.WaitForExit();
                }
                _firefox_process.Dispose();
                _firefox_process = null;
            }

            if (_profile_dir != null && !this.Persistant && Directory.Exists(_profile_dir)) {
                IOExt.DeleteDirectoryByShell(_profile_dir);
                _profile_dir = null;
            }
        }
        public void Start(IEnumerable arguments, Dictionary preferences, IEnumerable extensions, Dictionary capabilities, string profile, bool persistant) {
            this.Arguments = arguments;
            this.Preferences = preferences;
            this.Extensions = extensions;
            this.Capabilities = capabilities;
            this.Profile = profile;
            this.Persistant = persistant;

            string debugAddress;
            if (capabilities.TryGetValue("debuggerAddress", out debugAddress)) {
                _endpoint = EndPointExt.Parse(debugAddress);
                return;
            }

            _endpoint = EndPointExt.Create(IPAddress.Loopback, false);

            Thread thread = new Thread(RunStart);
            thread.Start();
            thread.Join();
            if (_exception != null)
                throw _exception;
        }
 public DriverService(IPAddress address) {
     _library_dir = IOExt.GetAssemblyDirectory();
     _arguments = new List<string>();
     _temp_folder = DriverService.GetTempFolder();
     _endpoint = EndPointExt.Create(address, false);
 }