internal void DiscoverInterpreterFactories()
        {
            if (Volatile.Read(ref _ignoreNotifications) > 0)
            {
                return;
            }

            DiscoveryStarted?.Invoke(this, EventArgs.Empty);

            // Discover the available interpreters...
            bool anyChanged = false;

            IWorkspace workspace = null;

            lock (_factories) {
                workspace = _workspace;
            }

            List <PythonInterpreterInformation> found;

            try {
                found = FindWorkspaceInterpreters(workspace)
                        .Where(i => !ExcludedVersions.Contains(i.Configuration.Version))
                        .ToList();
            } catch (ObjectDisposedException) {
                // We are aborting, so silently return with no results.
                return;
            }

            var uniqueIds = new HashSet <string>(found.Select(i => i.Configuration.Id));

            // Then update our cached state with the lock held.
            lock (_factories) {
                foreach (var info in found)
                {
                    PythonInterpreterInformation existingInfo;
                    if (!_factories.TryGetValue(info.Configuration.Id, out existingInfo) ||
                        info.Configuration != existingInfo.Configuration)
                    {
                        _factories[info.Configuration.Id] = info;
                        anyChanged = true;
                    }
                }

                // Remove any factories we had before and no longer see...
                foreach (var unregistered in _factories.Keys.Except(uniqueIds).ToArray())
                {
                    _factories.Remove(unregistered);
                    anyChanged = true;
                }
            }

            if (anyChanged)
            {
                OnInterpreterFactoriesChanged();
            }
        }
        private void DiscoverInterpreterFactories()
        {
            if (Volatile.Read(ref _ignoreNotifications) > 0)
            {
                return;
            }

            DiscoveryStarted?.Invoke(this, EventArgs.Empty);

            // Discover the available interpreters...
            bool anyChanged = false;

            List <PythonInterpreterInformation> found = null;

            try {
                // Try to find an existing root conda installation
                // If the future we may decide to install a private installation of conda/miniconda
                var globalFactories  = _globalProvider.GetInterpreterFactories().ToList();
                var mainCondaExePath = CondaUtils.GetLatestCondaExecutablePath(globalFactories);
                if (mainCondaExePath != null)
                {
                    found = FindCondaEnvironments(mainCondaExePath).ToList();
                }
            } catch (ObjectDisposedException) {
                // We are aborting, so silently return with no results.
                return;
            }

            var uniqueIds = new HashSet <string>(found.Select(i => i.Configuration.Id));

            // Then update our cached state with the lock held.
            lock (_factories) {
                foreach (var info in found.MaybeEnumerate())
                {
                    PythonInterpreterInformation existingInfo;
                    if (!_factories.TryGetValue(info.Configuration.Id, out existingInfo) ||
                        info.Configuration != existingInfo.Configuration)
                    {
                        _factories[info.Configuration.Id] = info;
                        anyChanged = true;
                    }
                }

                // Remove any factories we had before and no longer see...
                foreach (var unregistered in _factories.Keys.Except(uniqueIds).ToArray())
                {
                    _factories.Remove(unregistered);
                    anyChanged = true;
                }
            }

            if (anyChanged)
            {
                OnInterpreterFactoriesChanged();
            }
        }
        public async System.Threading.Tasks.Task ForceDiscoverInterpreterFactories()
        {
            DiscoveryStarted?.Invoke(this, EventArgs.Empty);

            // Discover the available interpreters...
            bool anyChanged = false;

            var found = new List <PythonInterpreterInformation>();

            try {
                found.AddRange(await FindCondaEnvironments());
            } catch (ObjectDisposedException) {
                // We are aborting, so silently return with no results.
                return;
            }

            var uniqueIds = new HashSet <string>(found.Select(i => i.Configuration.Id));

            // Then update our cached state with the lock held.
            lock (_factories) {
                foreach (var info in found)
                {
                    PythonInterpreterInformation existingInfo;
                    if (!_factories.TryGetValue(info.Configuration.Id, out existingInfo) ||
                        info.Configuration != existingInfo.Configuration)
                    {
                        _factories[info.Configuration.Id] = info;
                        anyChanged = true;
                    }
                }

                // Remove any factories we had before and no longer see...
                foreach (var unregistered in _factories.Keys.Except(uniqueIds).ToArray())
                {
                    _factories.Remove(unregistered);
                    anyChanged = true;
                }
            }

            if (anyChanged)
            {
                OnInterpreterFactoriesChanged();
            }
        }
 private static void OnBluetoothAdapterActionDiscoveryStarted()
 {
     DiscoveryStarted?.Invoke();
 }
Esempio n. 5
0
 // Fired when Bluetooth discovery is actually started
 // after call to BluetoothMultiplayerAndroid.StartListening()
 private void JavaDiscoveryStartedHandler(string empty)
 {
     DiscoveryStarted?.Invoke();
 }