using the .net API I would like to have some idea of progress when running a catchup subscription

I am using a catchup subscription like this

connection.SubscribeToStreamFrom(streamName,

LatestPosition,

true,

HandleEvent,

LiveProcessingStarted)

and in my handle event I would like to provide some indication of how close to live the subscription is, this does not have to be exact so just knowing the total event count at the start would be sufficient. is

var estimatedTotalEvents = connection.ReadStreamEventsBackwardAsync(streamName, 0, 1,false).Result.LastEventNumber;

the best way to get this number?

Thanks

R.

Yes.

There is also an indicator for in live vs polling mode. live mode
means you are pretty close to head.

Excellent, This is for a progress bar on projection load.

Now my next question is - I want the same behaviour for the all events stream.

I can get Positions using the equivalent methods, however I am not sure how to use that value to come up with an approximate percentage.

can I just use the CommitPosition fields and work that out as a percentage? or do I need to include the prepare position as well.

I just need an approximation for a progress bar while initializing (catching up) my read views, so this does not need to be very exact.

Thanks

Use the Max Prepare/Commit. (its still not perfect but should be
pretty close). If you are not using transactions prepare/commit will
always be the same value.