diff --git a/topics/basics/ide_infrastructure.md b/topics/basics/ide_infrastructure.md index 91ca78f7e..f448fe29f 100644 --- a/topics/basics/ide_infrastructure.md +++ b/topics/basics/ide_infrastructure.md @@ -92,3 +92,7 @@ To access relevant configuration directories, see [`PathManager`](upsource:///pl ## Context Help To show custom context web-based help for your plugin's functionality (e.g., for [dialogs](dialog_wrapper.md)), provide [`WebHelpProvider`](upsource:///platform/platform-api/src/com/intellij/openapi/help/WebHelpProvider.java) registered in `com.intellij.webHelpProvider` extension point. + +## Running Tasks Once + +Use [`RunOnceUtil`](upsource:///platform/core-api/src/com/intellij/ide/util/RunOnceUtil.java) to run a task exactly once per project/application. diff --git a/topics/basics/plugin_structure/plugin_components.md b/topics/basics/plugin_structure/plugin_components.md index 235c7733e..e2c1655ca 100644 --- a/topics/basics/plugin_structure/plugin_components.md +++ b/topics/basics/plugin_structure/plugin_components.md @@ -32,6 +32,7 @@ To subscribe to events, use a [listener](plugin_listeners.md) or create an [exte Executing code on application startup should be avoided whenever possible because it slows down startup. Plugin code should only be executed when projects are opened (see [Project Open](#project-open)) or when the user invokes an action of a plugin. If this cannot be avoided, add a [listener](plugin_listeners.md) subscribing to the [`AppLifecycleListener`](upsource:///platform/platform-impl/src/com/intellij/ide/AppLifecycleListener.java) topic. +See also [Running Tasks Once](ide_infrastructure.md). To execute an activity in background on IDE startup (e.g., to warm up caches), use [`PreloadingActivity`](upsource:///platform/platform-impl/src/com/intellij/openapi/application/PreloadingActivity.java). @@ -40,14 +41,16 @@ To execute an activity in background on IDE startup (e.g., to warm up caches), u To execute code when a project is being opened, use one of these two [extensions](plugin_extensions.md): `com.intellij.postStartupActivity` -: [`StartupActivity`](upsource:///platform/core-api/src/com/intellij/openapi/startup/StartupActivity.java) for immediate execution on EDT. Implement `DumbAware` to indicate activity can run in background thread (in parallel with other such tasks). +: [`StartupActivity`](upsource:///platform/core-api/src/com/intellij/openapi/startup/StartupActivity.java) for immediate execution on EDT. Implement `DumbAware` to indicate activity can run in background thread (in parallel with other such tasks). `com.intellij.backgroundPostStartupActivity` : [`StartupActivity.Background`](upsource:///platform/core-api/src/com/intellij/openapi/startup/StartupActivity.java) for execution with 5 seconds delay in background thread (2019.3 or later). Any long-running or CPU intensive tasks should be made visible to users by using `ProgressManager.run(Task.Backgroundable)`. -Access to indices must be wrapped with `DumbService`, see also [General Threading Rules](general_threading_rules.md). +Access to indices must be wrapped with `DumbService`, see also [General Threading Rules](general_threading_rules.md). + +See also [Running Tasks Once](ide_infrastructure.md). ### Application/Project Close -To execute code on project closing or application shutdown, implement the `Disposable` interface in a [Service](plugin_services.md) and place the code in the `dispose()` method. Alternatively, use `Disposer.register()` passing a `Project` or `Application` service instance as the `parent` argument (see [Choosing a Disposable Parent](disposers.md#choosing-a-disposable-parent)). \ No newline at end of file +To execute code on project closing or application shutdown, implement the `Disposable` interface in a [Service](plugin_services.md) and place the code in the `dispose()` method. Alternatively, use `Disposer.register()` passing a `Project` or `Application` service instance as the `parent` argument (see [Choosing a Disposable Parent](disposers.md#choosing-a-disposable-parent)).