Open rcm-adrien-gervaise opened 8 months ago
@LZorglub, would you be willing in principle to accept a PR that fixes this issue?
I dont see the use case of splitting years by blockcount and blocksize. Even in multi-threading threads work for close years. Isn't it simpler to not add the year in the dictionnary (UpdateDateChange) before fill it ?
Under heavily multi-threaded application, the optimized algorithm (
optimize = true
in e.g.TzTimeZone.ToUniversalTime
) can throwNullReferenceException
or other types of exceptions.The cause is that, while only one thread at a time can populate the offset changes cache in
UpdateDateChange
, other threads can read the cache while it is being modified withList<TzTimeZoneRuleDate> knownDate = _zoneDates[datetime.Year];
, which can result in non deterministic exceptions.One simple solution would be to have
UpdateDateChange
return the list of offsets for the year, all accesses would then be from inside the lock on_zoneDates
.