IBackgroundTaskInstance.GetDeferral 方法

定義

通知系統,背景工作可能會在 IBackgroundTask.Run 方法傳回之後繼續執行工作。

public:
 BackgroundTaskDeferral ^ GetDeferral();
BackgroundTaskDeferral GetDeferral();
public BackgroundTaskDeferral GetDeferral();
function getDeferral()
Public Function GetDeferral () As BackgroundTaskDeferral

傳回

背景工作延遲。

備註

如果背景工作使用非同步作業, 則 Run 方法可以在背景工作完成其工作之前傳回。 一旦 Run 方法傳回,系統可能會暫停或終止背景工作主機進程,以防止背景工作啟動的非同步作業完成。

若要讓主機進程在背景工作執行時暫停或終止,請使用 GetDeferral 方法來取得起始的每個非同步作業的背景工作延遲。 然後,當非同步作業完成時,呼叫 BackgroundTaskDeferral.Complete 方法。

請確定您完成所有背景工作延遲。 大部分的背景工作都有逾時,不論是否有任何擱置延遲,應用程式都會暫停或終止。 不過,離開未完成的背景工作延遲會干擾系統及時管理進程存留期的能力。

適用於