marsastro
✅ Compile visual studio project on linux?
I've developed a .net 7 console app in Visual Studio, and I'd like to deploy it on a VPS that runs linux so I don't have to run it locally (I don't keep my computer running at night).
I can just build it for linux and transfer that over, but I'm curious if there's a not too complicated way to build the project natively on linux. That way I can clone the repo and pull and recompile whenever I update the app, instead of always having to transfer a finished build over. Is there an easy way to do this?
9 replies
✅ Make process believe it's a startup app?
Hello!
So I'm building an app that starts another app. The app in question seems to behave differently depending on whether it was manually started or started as a startup app. When it's started through windows startup app system, it starts as an icon in the taskbar corner. However, when I manually start it, run it through Task Scheduler, or start it from my app, it starts with a window open that has to be manually closed for it to hang out in the taskbar corner like it does on startup.
I'm not quite sure how it achieves this. I assume that Windows either supplies some arguments when it starts an app, or this app has some other way to figure out that it was started by windows automatically. The app in question is f.lux.
Anyone have any idea how I can make it behave the same way when started manually? Like emulate the way windows launches apps through the startup procedure?
20 replies
❔ WPF not disposing of memory on window close
I'm developing a WPF app that mostly lives in the taskbar corner, but that can open a window to change settings.
When it's idling, it's using 38MB of memory.
When I open the window for the first time, it shoots up to about 100MB of memory. The issue is that when I close the window, most of this memory remains in use.
I've run some diagnostics and identified that the culprit is that during InitializeComponent the window loads a bunch of FontAwesome5 stuff (from external NuGet assemblies) into memory, and upon executing the Show command it adds hundreds of WeakReferences of the BindingExpression, ArrayList, ResourceDictionary, DependentList and AssemblyNameSpacePair types.
It's not a problem that these are loaded into memory, as 100MB still isn't a lot, but it seems like such a waste to keep them around after closing the window given that the app will most likely run for hours and rarely if ever need to open the window again.
Anyone have any idea why these resources aren't disposed of when Close is called, and how I can do something about that?
2 replies
✅ Await seemingly ignored inside Dispatcher.BeginInvoke
I'm writing an app in WPF. Currently testing something out, here's the code I'm testing:
What I want to happen is that the Task.Delay inside the BeginInvoke call will ensure that 1 second passes before the code beginning at _nameUpdateTaskRunning = false starts running. However, when I run this code, the focusable/enabled changes never happen, and the visibility changes happen immediately. I've confirmed by breakpoint debugging that the code block inside the if statement happens.
So I'm guessing that either the focusable/enabled changes aren't being applied, or the awaiting of Task.Delay isn't happening properly and the code keeps running and does the next Dispatcher.Invoke immediately. Does anyone know which it is, and what I can do to fix it?
11 replies
✅ Scheduling with irregular and long intervals
Hello, I'm developing an app that will run 24/7 on a server, and I want to schedule it to do something. It's a console app running .NET 7.
I want it to do a thing every hour between 8-16 on wednes, in which it's checking if something has been updated. If it hasn't it will keep doing this for the next two days as well. If it finds an update, or there is no update within 16:00 on Friday, it will stop looking and wait until the next Wednesday and start over again.
The app is entirely based around async Task operations, and technically I could have a while loop with calls to Task.Delay with very high values, but that method just doesn't seem very viable to me. It could result in an almost 7 day long waiting time, and that seems like it's not a great way to use Task.Delay.
So, I'm looking for some tips and suggestions on a good way to schedule the app to work the way I've described. Alternatively if using Task.Delay is a perfectly viable way to achieve this, then please let me know and I'll just do it that way!
5 replies
❔ ✅ HttpListener only receives context once
Hey, I've set up a class that listens for traffic on localhost coming from a different app. The class looks like this:
Everything in the try block runs once, and then execution goes back to the top of the loop and starts awaiting the _listener.GetContextAsync() call again. But it never does anything else, and I know for a fact the traffic it receives at localhost:8000 happens periodically. So it picks up the first one it receives, and then it just stops doing anything. It never enters the catch block, so there isn't any exception thrown.
12 replies
✅ JsonConvert debugging help
Hello! I'm having a hard time figuring out how to solve an issue where JsonConvert.DeserializeObject is struggling to parse a weird data structure.
Essentially I'm getting an object like this: {"powerup":{"on":{"on":{"on":true}}}}
There are more objects and values, but I'm omitting them as they're not relevant to the parsing error
In other words, an object called powerup with an object called on, that has an object called on, that has a bool called on. Very odd data structure, I know, but unfortunately this is what the API I'm consuming is giving me.
A json converter tool suggested this:
However, this reads to a parsing error saying that { after the second on objects : is an unexpected character. Which makes sense, as it's expecting a bool, not an object. So I tried to fix it by doing this:
However, now I'm getting the error that it fails to convert a boolean value to the type On2, which seems to suggest that it's now suddenly reading it correctly as a bool and trying to set the On2 on variable with this bool value.
I'm very confused at this point. Anyone have any idea what's going on here?
17 replies
❔ ✅ Help choosing a framework
Hello!
I'm making a little windows app that's got a healthy mishmash of requirements, and not being too familiar with the windows frameworks or windows desktop app development in general I'm having a hard time figuring out what suits my needs best. Here's what the needs to do:
1. Be installable through a setup wizard (I will share this software with people who can't build the app from code themselves)
2. Run on startup after installation
3. Sit in the taskbar corner by default
4. Have a simple tiny gui pop up when you press the corner icon (and maybe a context menu on right-click)
5. Act as a local webserver that listens for web requests on localhost (a simple HttpListener is sufficient here)
6. Consume a restful API (of a device on the same local network as the computer) (I think an HttpClient will be all I need here as the api is somewhat simple, but I might possibly consider an external library like flurl or refit for convenience)
As far as I can tell, the taskbar corner part seems like a hassle to deal with in terms of WPF. Winforms can more easily do that part, but it's not as good as WPF when it comes to GUI. I haven't looked much into maui and WinUI 3, but those also seem like candidates. If anyone has experience with apps like Steam, f.lux or voicemeeter, this is the style of "startup taskbar app" I'm thinking of.
As some of you might be able to tell, it's point 1-4 I'm mostly in the dark about. Point 5-6 I know how to do each of them in isolation, but I added them just in case these two points don't play well together, don't match well with point 1-4, or rules out any of the frameworks. I'm also wondering whether it would be better for some or all of the HTTP work to be largely done as a windows service or if it could all be contained within the app itself as a sort of multi-threaded/asynchronous task based app.
I'm developing in VS2022 Community if that matters. Any input would be greatly appreciated! 🥳
9 replies