Contents

performAsCurrent(withPendingUnitCount:using:)

Retrieves the current thread’s progress object, executes the specified block, and increments the progress object by the specified units of work.

Declaration

func performAsCurrent<ReturnType>(withPendingUnitCount unitCount: Int64, using work: () throws -> ReturnType) rethrows -> ReturnType

Parameters

  • unitCount:

    The number of units of work to increment for the current progress object. This number represents the portion of work that is complete in relation to the total number of units of work for the current thread’s progress object. The units of work for this parameter must be the same units of work as the current progress object’s Totalunitcount property.

  • work:

    A block that wraps the work you specify to complete for incrementing the current progress.

Return Value

The return type and value of the block that you specify for the work parameter.

Discussion

Use this function as a convenience method to wrap an existing method or block to increment the current progress object. This function retrieves the current progress object, does the work you specify in the work block, and returns the value from that block. When the block is complete, this function increments the current progress object. This function is the same as calling becomeCurrent(withPendingUnitCount:), doing the work you specify in the block, and calling resignCurrent().

See Also

Accessing the Current Progress Object