4 ms·
> c# doesn't have anything like weak pointers https://docs.microsoft.com/en-us/dotnet/api/system.weakreference https://docs.microsoft.com/en-us/dotnet/api/syst
by Const-me 7y ago
> c# doesn't have anything like weak pointers
https://docs.microsoft.com/en-us/dotnet/api/system.weakreference https://docs.microsoft.com/en-us/dotnet/api/system.weakrefer...
https://docs.microsoft.com/en-us/dotnet/api/system.weakreference-1 https://docs.microsoft.com/en-us/dotnet/api/system.weakrefer...
https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.conditionalweaktable-2 https://docs.microsoft.com/en-us/dotnet/api/system.runtime.c...
> event handlers require that you manually dispose of half your objects.
You probably have software design issue on your day job. C# events can be great, but they're not a silver bullet.
For loosely coupled application wide events, event aggregator pattern works better, see IEventAggregator from Caliburn.Micro for an example.
If the two sides of the event handlers need strong coupling for a good reason, an interface or abstract class for the consumer works better, see ExpressionVisitor from System.Linq.Expressions for an example.
- pjmlp 7y agoYou forgot to add safe handles as well. https://docs.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.safehandle?view=netframework-4.8 https://docs.microsoft.com/en-us/dotnet/api/system.runtime.i... This and the the thread of the other day regarding having to use C for what C# is capable of, apparently many don't look on their toolboxes.