OptionsMonitorExtensions.OnChange<TOptions>(IOptionsMonitor<TOptions>, Action<TOptions>) 方法

定義

註冊每當 TOptions 變更時要呼叫的接聽程式。Registers a listener to be called whenever TOptions changes.

public:
generic <typename TOptions>
[System::Runtime::CompilerServices::Extension]
 static IDisposable ^ OnChange(Microsoft::Extensions::Options::IOptionsMonitor<TOptions> ^ monitor, Action<TOptions> ^ listener);
public static IDisposable OnChange<TOptions> (this Microsoft.Extensions.Options.IOptionsMonitor<TOptions> monitor, Action<TOptions> listener);
static member OnChange : Microsoft.Extensions.Options.IOptionsMonitor<'Options> * Action<'Options> -> IDisposable
<Extension()>
Public Function OnChange(Of TOptions) (monitor As IOptionsMonitor(Of TOptions), listener As Action(Of TOptions)) As IDisposable

類型參數

TOptions

參數

monitor
IOptionsMonitor<TOptions>

IOptionsMonitor。The IOptionsMonitor.

listener
Action<TOptions>

TOptions 產生變更時要叫用的動作。The action to be invoked when TOptions has changed.

傳回

應進行處置以停止接聽變更的 IDisposableAn IDisposable which should be disposed to stop listening for changes.

適用於