C
C#•5mo ago
PurplePeopleEater

The taskbar icon for my app becomes orphaned

Under the following circumstances the taskbar icon for my app becomes orphaned. In other words, my app is no longer running but the taskbar icon is still visible until I hover my mouse pointer over it which causes it to disappear. 1) If my app crashes 2) If I press the Stop button in the Visual Studio Debugger Questions: 1) Is there a way to make sure the taskbar icon gets removed if scenario #1 above takes place? 2) Is there a way to make sure the taskbar icon gets removed if scenario #2 above takes place? Thank you!
12 Replies
ACiDCA7
ACiDCA7•5mo ago
its a windows quirk. so without doing some crazy shenanigans there is no way.
PurplePeopleEater
PurplePeopleEater•5mo ago
Hi ACiDCA7, thank you for the response. What crazy shenanigans would I have to do?
ACiDCA7
ACiDCA7•5mo ago
believe me you dont want to do them, instead just fix your app so it doesnt crash, and regarding stopping debugging, well its just something you have to deal with as a dev
PurplePeopleEater
PurplePeopleEater•5mo ago
well, I already built a visual studio plugin that automatically cleans up orphaned icons when hitting the Stop button in the debugger. I also created a separate app that runs in the background and kills orphaned icons every 5 seconds to handle the issue of the app crashing. So... I am pretty willing to deal with lots of shenanigans. At this point, I am just hoping to get rid of one or both of these solutions and have the "fix" built into the main app. Also, I am hoping that the solution will not be spawning a helper app that waits for its parent (main) app to exit (by crashing or getting killed by the debugger) and then kills any orphaned icons. So, what would the shenanigans be that you had in mind?
ACiDCA7
ACiDCA7•5mo ago
pretty much what you just wrote, have a second application clean up the mess that got left behind of a crashed app. imho this is just wasted time coding and wasting cpu cycles. the clean solution is to just fix your code and have it gracefully shutdown on non recoverable errors. better would be to not have these kind of errors at all, but well sometimes just not possible why are you so fixated on the leftover icons? it happens in teams, in sourcetree and many more apps. if the processes die windows wont get notified to remove the icon until it notices by itself, which is in most cases, on hover. also if you now write some stuff like this, who guarantees that that app doesnt crash? will you write another app?
PurplePeopleEater
PurplePeopleEater•5mo ago
"the clean solution is to just fix your code and have it gracefully shutdown on non recoverable errors. better would be to not have these kind of errors at all, but well sometimes just not possible" - my code is not currently crashing, but I am sure I will re-introduce crashes as I work on the app. Also, I will be creating other apps that use taskbar icons so I expect this to be a continuing problem going forward - that is why I am hoping to come up with a clean solution. "why are you so fixated on the leftover icons? it happens in teams, in sourcetree and many more apps. if the processes die windows wont get notified to remove the icon until it notices by itself, which is in most cases, on hover." - what typically happens is that I run my app many dozens of times during a day of working on my app. Each crash, and more commonly, each time I hit the Stop button I end up with an additional orphaned icon. It would be OK if there was always a total of one orphaned icon but it keeps adding more. Eventually they cause the taskbar icon area to eat up so much space that it shrinks the space to the left of it for the running apps which means I get a lovely scrollbar to locate my running apps. At that point I am forced to hover with my mouse to get rid of the scroll bar. Also, I try to use the mouse as little as possible to avoid recreating my healed RSI. And also the many orphaned icons just annoy the heck out of me. "also if you now write some stuff like this, who guarantees that that app doesnt crash? will you write another app? " - not sure what you meant by this comment
SinFluxx
SinFluxx•5mo ago
You're writing app B to look out for a possible issue from app A, so will you write app C to look out for a possible issue from app B, then app D to look out for possible issues from app C, then... i.e. given that it's a pretty minor issue, your time is better spent just working on app A and sorting out any issues with it directly
PurplePeopleEater
PurplePeopleEater•5mo ago
Thank you for weighing-in SinFluxx. I understand what you are saying. I was just hoping that there was a reasonable solution that I was just unaware of. Like maybe some way to get the Finalizer or the Dispose method to do it. To be clear I already tried those and I couldn't get them to work but I was hoping that I was just making a mistake that someone more knowledgable would be able to point out and not that it is just .NET and Windows not supplying a way to deal with these scenarios
ACiDCA7
ACiDCA7•5mo ago
maybe just have a close button? so you dont stop via VS
PurplePeopleEater
PurplePeopleEater•5mo ago
Yes, I already have a close button (menu item really) but sometimes it is more convenient to hit the Stop button and sometimes apps crash (and my close menu item does the taskbar icon cleanup already) @ACiDCA7 Would it be possible for you to take a look at my other taskbar icon related question from earlier today? https://discord.com/channels/143867839282020352/1210625651393175664 @SinFluxx What do you think about my other taskbar icon related question from earlier today? https://discord.com/channels/143867839282020352/1210625651393175664
ACiDCA7
ACiDCA7•5mo ago
i havent had that problem yet when it wasnt caused by myself, so cannot help there. try writing some logs
PurplePeopleEater
PurplePeopleEater•5mo ago
Ok, thank you for the feedback 🙂 bump