Relevant
Long running process in Blazor Server
I have a Blazor Server app, and I have a page that will kick off a long running process. I am calling an async method without an await in order to get the response back quickly, and it is starting the processes fine. But it seems like whenever there is a long running syncronous task running in the background, it will lock the UI thread. How can I make this process run in a way that doesn't block the UI thread?
Here's a sample project to show what I mean:
64 replies
StreamReader is always EndOfStream=true even before reading
So this code works when I run locally with a file name hard coded in. When I instead download the the file and load it into a FileStream, it's always at EndOfStream. Am I doing something wrong?
Here's what the code would look like in the way it's NOT working:
18 replies
SSH.NET hide terminal junk
This might be a long shot, but is there anyone here that's familiar with SSH.NET and know if there's some sort of terminal mode that shows cleaner output, so I don't have to filter out things like
serverName /some/place $: my -command
?3 replies
How to know if Serilog fails
I'm assuming that Serilog fails silently if there are issues. I'm trying to log to elasticsearch and I don't see them coming through. I'm assuming it's an issue with authentication, but I'm not seeing any error. Anyone know how I can have the logging thrown an exception or show errors in some way?
25 replies
SFTP through a proxy server
I'm using SSH.NET and since I'm unable to connect to production servers directly, I have to first SSH into an intermediary server (using a private key), which I can than use to SSH into the prod servers. It's working-ish, but I'm doing everything through shell streams and using regular expressions to filter the linux output. It's a bit of a mess. I'd really like to use SFTP to check files, but I haven't yet figured out a way to do this through another server using a private key.
I know it's a long shot, since this is a pretty specific need, but figured I'd check here to see if anyone has any ideas.
6 replies
❔ Improving performance for Process.Start
I have an application that will run a python script using Process.Start. At the end, I'm reading the output with
process.StandardOutput.ReadToEnd()
. If I run the script on it's own, it runs in about 1 second. But running it this way takes about 2 seconds. Is there any way I could reduce some overhead? Is reading output time consuming?14 replies
❔ Mock linux server
I'm trying to write some unit tests for an application I created that will ssh into several servers and check some configurations, etc.
Is there a good way to mock this? Could I do some dummy server somehow, or mock a SshClient?
I'm certainly not super experienced when it comes to unit testing. Would it be fine to just use Moq and give a SshClient/ShellStream a Setup and Returns to just return some dummy data back from the calls?
7 replies
❔ How to restart a BackgroundService
Searching the internets, I seem to be finding answers that don't really seem right, and not good even if they are right.
Is there a way to get the instance of a hosted service that may have stopped so that I can restart it?
I tried this, but service ended up being
null
in this case:
11 replies
❔ ✅ Choosing an appropriate data structure
So I have a list of objects and I want one in the list to be active and the rest to be inactive.
I was thinking of using a
Dictionary<Thing, bool>
where the bool is if it's active or not. I guess this would work, but then I'd have to do something like myDict.FirstOrDefault(d => d.Value == true).Key
which feels a little clunky22 replies
❔ ✅ Best practice for tracking progress for long running method
I am creating a Blazor Server application. I have a method that is compiling some data from a few servers. I'd like to show some sort of progress bar to show the user approximately how much is left. Currently the method just returns a List of all of the objects that was compiled during the process. This is being done in a service class, so I wouldn't have access to the UI elements from the method.
So is there a way to send progress information back to the caller periodically?
I could refactor the method to do 1 server at a time, that way I'll know, for example, that it's 3 of 8 completed, etc. And I could break it down even further to split apart each section of processing to get even more granular. But that seems like it could be more work than it's worth for just a UI nicety. Is there some super neat way of doing this better?
5 replies
❔ Transferring data to python script
I'm building a C# app that can run python scripts. I'm doing the database queries on the C# side, seems to be more efficient.
I'm currently just throwing the data into a text file to be read by the python script. It works, but wondering if I'd be able to shave a few milliseconds by using some other mechanism for transferring data. Any ideas?
10 replies