src/vs/workbench/contrib/notebook/browser/contrib/kernelDetection/notebookKernelDetection.ts/NotebookKernelDetection/_registerListeners
class NotebookKernelDetection:	private _registerListeners() {
		this._localDisposableStore.clear();

		const kernelPickerType = this._configurationService.getValue<'all' | 'mru'>('notebook.kernelPicker.type');

		if (kernelPickerType === 'mru') {
			this._localDisposableStore.add(this._extensionService.onWillActivateByEvent(e => {
				if (e.event.startsWith('onNotebook:')) {
					if (this._extensionService.activationEventIsDone(e.event)) {
						return;
					}

					// parse the event to get the notebook type
					const notebookType = e.event.substring('onNotebook:'.length);

					let shouldStartDetection = false;

					const extensionStatus = this._extensionService.getExtensionsStatus();
					this._extensionService.extensions.forEach(extension => {
						if (extensionStatus[extension.identifier.value].activationTimes) {
							// already activated
							return;
						}
						if (extension.activationEvents?.includes(e.event)) {
							shouldStartDetection = true;
						}
					});

					if (shouldStartDetection) {
						const task = this._notebookKernelService.registerNotebookKernelDetectionTask({
							notebookType: notebookType
						});

						this._detectionMap.set(notebookType, task);
					}
				}
			}));

			let timer: any = null;

			this._localDisposableStore.add(this._extensionService.onDidChangeExtensionsStatus(() => {
				if (timer) {
					clearTimeout(timer);
				}

				// activation state might not be updated yet, postpone to next frame
				timer = setTimeout(() => {
					for (const [notebookType, task] of this._detectionMap) {
						if (this._extensionService.activationEventIsDone(`onNotebook:${notebookType}`)) {
							task.dispose();
						}
					}
				});
			}));

			this._localDisposableStore.add({
				dispose: () => {
					if (timer) {
						clearTimeout(timer);
					}
				}
			});
		}
	}