I'm a little unsure of the lifetime of a template context or how I should handle my requirement. I have X clients sending Y campaigns and each campaign may have Z members. When a campaign is sending (they could be sending concurrently), the logic is straightforward:

Pseudocode. Campaigns are broken into batches of 1000. The following code would be for one batch. Campaigns could top out at 500-1000 batches:

Should I instantiate a new templatecontext per campaign? The example on the site uses the Virtual File system is that more performant is this pseudocode the recommended way? Thanks.

Edit: I have tested creating a new Template context for each batch and it is very fast. After dealing with Razor engine with a similar situation that was my fear as it was pretty slow. Pretty happy with the performance here.

mythz
—
2018-05-18T20:09:31Z —
#2

When in a loop you should reuse the same TemplateContext instance so the delegate caches populated when Templates are evaluated can be reused.