Multiframe workItem I don't understand the docs on how to use

I want to run an ExpensiveWI() over multiple frames, but it keeps blocking and finishing in one frame. the docs say “The “force” parameter will be true if the work item is required to complete immediately.” but I understand what The “force” parameter is.
I am calling like this

AstarPath.active.AddWorkItem(new AstarWorkItem(() => {},
force => {ExpensiveWI(); return true;}
));

How should I call this to get it run over multiple frames on another thread?

You can run work items over multiple frames:
AstarPath.active.AddWorkItem(new AstarWorkItem(() => {
// Called once, right before the
// first call to the method below
},
force => {
// Called every frame until complete.
// Signal that the work item is
// complete by returning true.
// The “force” parameter will
// be true if the work item is
// required to complete immediately.
// In that case this method should
// block and return true when done.
return true;
}));

Hi

If you return false from the work item, it will continue calling your function until it returns true (indicating that its done).

You’ll have to split your ExpensiveWI function into smaller steps yourself, though. For example using an IEnumerator or similar.

Thanks, I see this more like a Unity Job than a C# thread.