Partager via


AsyncTaskLoader.LoadInBackground Method

Definition

Called on a worker thread to perform the actual load and to return the result of the load operation.

[Android.Runtime.Register("loadInBackground", "()Ljava/lang/Object;", "GetLoadInBackgroundHandler")]
public abstract Java.Lang.Object? LoadInBackground ();
[<Android.Runtime.Register("loadInBackground", "()Ljava/lang/Object;", "GetLoadInBackgroundHandler")>]
abstract member LoadInBackground : unit -> Java.Lang.Object

Returns

The result of the load operation.

Attributes

Exceptions

if the load is canceled during execution.

Remarks

Called on a worker thread to perform the actual load and to return the result of the load operation.

Implementations should not deliver the result directly, but should return them from this method, which will eventually end up calling #deliverResult on the UI thread. If implementations need to process the results on the UI thread they may override #deliverResult and do so there.

To support cancellation, this method should periodically check the value of #isLoadInBackgroundCanceled and terminate when it returns true. Subclasses may also override #cancelLoadInBackground to interrupt the load directly instead of polling #isLoadInBackgroundCanceled.

When the load is canceled, this method may either return normally or throw OperationCanceledException. In either case, the Loader will call #onCanceled to perform post-cancellation cleanup and to dispose of the result object, if any.

Java documentation for android.content.AsyncTaskLoader.loadInBackground().

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

See also