Abdesol
Abdesol
CC#
Created by Abdesol on 6/27/2024 in #help
How to handle outputs that alter the same line and remove lines while running a process?
Hello, I am trying to run a process in a C# program and the process output alters on the same line. Like, it shows percent, and then removes some lines and shows another line. Currently, using StandardOutput, I am not able to capture such scenarios. Is there any workaround to this? Thank you!
9 replies
CC#
Created by Abdesol on 6/20/2024 in #help
cancellation token to stop Console.ReadLine is only working on the first try
I have the following method I got from stackoverflow
async Task<string?> ReadLineAsync(CancellationToken cancellationToken = default)
{
var readTask = Task.Run(() => Console.ReadLine());
await Task.WhenAny(readTask, Task.Delay(-1, cancellationToken));
cancellationToken.ThrowIfCancellationRequested();
return await readTask;
}
async Task<string?> ReadLineAsync(CancellationToken cancellationToken = default)
{
var readTask = Task.Run(() => Console.ReadLine());
await Task.WhenAny(readTask, Task.Delay(-1, cancellationToken));
cancellationToken.ThrowIfCancellationRequested();
return await readTask;
}
I run it in a loop while passing it a cancellation token.. and the cancellation token is also in a loop, which means, I recreate it every time.. it works on the first try.. but after the recreation starts for the cancellation token, on await Task.WhenAny(readTask, Task.Delay(-1, cancellationToken)); cancellation token doesn't get to end first although it should have from the other concurrent task I manage to cancel the token. What could be a possible solution? Thank you!
93 replies
CC#
Created by Abdesol on 6/1/2024 in #help
when do I need to learn dotnet aspire?
I am trying to get into backend web dev with dotnet using asp.net core and the other tools. I was looking through the roadmap provided by Nick Chapsas (https://roadmap.sh/r?id=65d8624e66cd6d03d2d7efc9), and it put dotnet aspire before asp.net core basics. When I try to look into how I can learn dotnet aspire, they all are using some form of asp.net apis. So, is it necessary that I learn it first or let me do it after I get comfortable with asp.net core? Thank you!
7 replies
CC#
Created by Abdesol on 5/9/2024 in #help
On deserializing using Newtonsoft, I get default constructor required issue on mac but not on window
I am trying to use the ChatGPT nuget package <PackageReference Include="OpenAI" Version="1.11.0" /> which have to deserialize json for data processing. It works normally on windows, but on macos, I face the error below:
Newtonsoft.Json.JsonSerializationException: Unable to find a constructor to use for type OpenAl_API.EndpointBase+ApiErrorResponse. A class should either have a default constructor, one constructor with arguments or a constructor marked with the JsonConstructor attribute.
Newtonsoft.Json.JsonSerializationException: Unable to find a constructor to use for type OpenAl_API.EndpointBase+ApiErrorResponse. A class should either have a default constructor, one constructor with arguments or a constructor marked with the JsonConstructor attribute.
My target framework for windows is net8.0, and for macos, it is net8.0-macos. I have tried to switch to another ChatGPT package, but similar issue arises. Is there any fix for this issue? Thank you!
28 replies
CC#
Created by Abdesol on 1/19/2024 in #help
sql-net-pcl library, UpdateAll method is always returning 0, resulting in no update.
No description
20 replies
CC#
Created by Abdesol on 8/8/2023 in #help
✅ Bass Library Error: Device(Illegal Device Number)
I am having hard time with using the bass library on MacOS. I am not able to get rid of the Device(Illegal Device Number) issue after publishing. It works perfectly in debug mode. After publishing for microsoft windows too, it is having problem but I am not sure about that. But I am sure about the MacOS problem.
15 replies
CC#
Created by Abdesol on 7/22/2023 in #help
I am trying to reference a .csproj to my project, but it is throwing this error...
86 replies
CC#
Created by Abdesol on 4/26/2023 in #help
How to Dump and save objects to a file to load them later?
So, I was trying to use the Razorvine.Pickle library for this.. pickling them is working.. but unpickling is resulting in casting errors.. Is there any alternative I can use to save objects to a file? Thank you!
59 replies
CC#
Created by Abdesol on 3/20/2023 in #help
❔ Crossplatform disk formatting code
21 replies