Monday, November 8, 2021

Persistent variables for method scope only (V) - Conlusion

After elaborating all the stuff shown in previous articles, we can state, that it works somehow, even quite secure with the use of StackFrame, but so slowly that you cannot use it in production code. Furthermore the need of implement INotifyDispose for the use of non-static persistent values blows up code and impure implementation or missing object disposal leads to memory leakage. And the correct use of the ref syntax in consumption code is an additional obstacle to take care of.

For my personal claims too many drawbacks, so I decided for "Hands off!". Let's use such a festure, if it's baked in native C# and until then, use member or static class fields ...

But it was quite fun to noodle around the topic and I've learned a little bit more about the ref syntax I didn't use yet so much.

One more disclaimer: If you ever gone use the posted code from the previous articles, please be aware that this code is not yet thread safe! You can make it thread safe with corresponding locking techniques. Please keep this in mind!

And if you ever have some idea how to simplify or improve the posted solution attempt, please let me know in your comment. I'm eager to hear it :)

No comments:

Post a Comment