The Don
The Don
CC#
Created by The Don on 12/28/2023 in #help
Environment Variables/Persistent Values in OpenSilver
Dear Community - I am trying to find a way to store and recall user credentials (such as an API key from a back-end or other user-critical data) when using an OpenSilver project, and haven't had much luck. I was wondering if the community could offer an insight on this. What I've tried (without success) : - Environment Variables (Using System.Environment). - User Secrets. - Storing a file in the file system. Thank you, kindly!
9 replies
CC#
Created by The Don on 11/3/2023 in #help
✅ Is use of IDisposable, using keyword for a UI wait indicator incorrect?
I have a wait indicator for WPF that implements IDisposable. When creating a new object of this IDisposasble implementation wrapped in a using keyword, it initializes the wait indicator on my WPF screen. Upon disposing, the wait indicator disappears. This is the code I used before implementing IDisposable:
async Task LongRunningTask1()
{
_waitIndicator.Show("Waiting")

await Task1();

if(cancel)
{
_waitIndicator.Hide(); // Accounts for early return

return;
}

await Task2();

_waitIndicator.Hide()
}
async Task LongRunningTask1()
{
_waitIndicator.Show("Waiting")

await Task1();

if(cancel)
{
_waitIndicator.Hide(); // Accounts for early return

return;
}

await Task2();

_waitIndicator.Hide()
}
Here I have an early return, so I have to call waiter.hide() twice. This is a simple case, so it may seem trivial to call it more than once, but this can cause problems when the code is more complicated. Forgetting to hide() will obviously hang the UI. On the other hand, using this code:
async Task LongRunningTask2()
{
using(new _waitIndicator.Show("Waiting"))
{
await Task1();

if(cancel)
{
// No need to "hide" the wait indicator, instead, it is done when the
// using statement ends.
return;
}

await Task2();
}
}
async Task LongRunningTask2()
{
using(new _waitIndicator.Show("Waiting"))
{
await Task1();

if(cancel)
{
// No need to "hide" the wait indicator, instead, it is done when the
// using statement ends.
return;
}

await Task2();
}
}
Seems more simplistic and readable. I am wondering if there are any problems with this. If so, are there any alternatives to this? Thanks!
43 replies
CC#
Created by The Don on 6/19/2023 in #help
❔ Data Plotting Library that Exports Directly to Image
Dear Community, I am currently a SciChart WPF user that wants to export their charts to file. However, SciChart is a WPF library and uses WPF elements to render its charts, meaning that if I want to export a chart to an image, the end user has to first make the chart visible and then export the chart from there. This is not a feature I want in my user-friendly WPF software, I'd like to use a free/open-source C# library that exports charts to an image file that looks similar to matplotlib does in Python just for the sake of exporting the chart to an image, so that I can use it alongside SciChart. Any suggestions? Thank you in advance!
3 replies
CC#
Created by The Don on 1/15/2023 in #help
❔ VS2022 iOS Simulator Fatal Error - MacInCloud
2 replies
CC#
Created by The Don on 10/25/2022 in #help
Running MongoDump from C-Sharp Program in Linux Docker Container
Dear community, I am trying to write a Docker container that will automatically back up all my MongoDB data that's on another server. It should run mongodump on my MongoDb database (dbName) and then storing the archive as the designated file (mongoDumpPath). When I try to run this in C#, noting happens, (i.e. I can't see the archive file, the result string is empty). However, when I copy and paste the mongoDumpCommand string variable and paste it onto the bash shell of the container, it works perfectly.
// Create mongodump command.
var mongoDumpCommand = $"mongodump --uri=\"mongodb://{host}:{port}\" --db=\"{dbName}\" --archive=\"{mongoDumpPath}\"\r\n";

// Set the options of the process.
var startInfo = new ProcessStartInfo
{
FileName = "/bin/bash",
Arguments = mongoDumpCommand,
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true,
};

var process = new Process
{
StartInfo = startInfo
};

// Start the process and wait for it to finish.
process.Start();
await process.WaitForExitAsync();

// Get the mongodump logs.
var result = await process.StandardOutput.ReadToEndAsync();
// Create mongodump command.
var mongoDumpCommand = $"mongodump --uri=\"mongodb://{host}:{port}\" --db=\"{dbName}\" --archive=\"{mongoDumpPath}\"\r\n";

// Set the options of the process.
var startInfo = new ProcessStartInfo
{
FileName = "/bin/bash",
Arguments = mongoDumpCommand,
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true,
};

var process = new Process
{
StartInfo = startInfo
};

// Start the process and wait for it to finish.
process.Start();
await process.WaitForExitAsync();

// Get the mongodump logs.
var result = await process.StandardOutput.ReadToEndAsync();
Can you please advise? Thanks kindly! EDIT: The StandardError output shows an "unable to execute binary file" even though chmod +x /usr/bin/mongodump is in the Dockerfile.
1 replies
CC#
Created by The Don on 9/22/2022 in #help
C-sharp Video Extraction Libraries
I am looking for a good, preferably open-source library for importing video files (e.g. AVI) into an array of 2-D pixels matrices for each frame, that can be used for analysis in C#. Can anyone recommend anything? Thanks!
1 replies