✅ Unsubscribing from all events
Okay, to make it short, I need to unsubscribe from an anonymous event and the way I thought would work would just to unsub from all by using
.GetInvocationList()
but it appears it just doesn't exist, can anyone give a tip on how to do it ?19 Replies
@Windows10CE thought I'd ping you if you don't mind
what was ph
in that small snippet you sent
actually, could you just throw it all in $paste
If your code is too long, you can post to https://paste.mod.gg/ and copy the link into chat for others to see your shared code!
fits in here
unless you really want it in $paste
If your code is too long, you can post to https://paste.mod.gg/ and copy the link into chat for others to see your shared code!
ah, it's not your class
then all you can do really is keep track of your subscriptions yourself, or use reflection
why do you need to unsubscribe anyway?
because for some unknown reasons, it reapeats the progress two times
I mean I kndi know why but not how to fix it
I don't think this will fix it
like it does 0 to 100 when it downloads the files and 0 to 100 again when it's reading the stream, copying or whatever operation on it
you could try just having a bool
that says whether to handle the event or not
and check that in your delegate
oh
oh btw
whats the difference
between
ph.HttpReceiveProgress += delegate(object? _, HttpProgressEventArgs args) { onDataReceived?.Invoke(args); };
and ph.HttpReceiveProgress += (sender, args) => onDataReceived?.Invoke(args);
the first is just older syntax
I'd always do the second one
oh okay
thanks for the tip
I'll try the bool to see if it fixes it
ah
idk why that's given as a warning
should work fine
and it does
bar just stays full for a long period of time now
gotta find some sketchy workaround
Task.Run moment
nah I think it's fine
or wait
hold my beer
bro I'm so smart
kinda cheating but it works just fine
thanks again for your help and time
you can close the thread if you can once you saw this
unsubbing all = setting to null
isn't that allowed with events?
yeah ig probably not
not if you're not in the declaring class