Burrito
Burrito
CC#
Created by InfinityShadow20 on 1/31/2024 in #help
Switching language Versions:
How did you create your old project?
206 replies
CC#
Created by InfinityShadow20 on 1/31/2024 in #help
Switching language Versions:
You don't have to use notepad as a middle man, you can just make a new project in a new folder, and copy over the .cs files from your old project.
206 replies
CC#
Created by MechWarrior99 on 1/21/2024 in #help
How to safely access parameters from Task (Porting from Unity IJob)
I've been spoiled by Unity's Job system and UniTask.RunOnThreadPool that I didn't know about this.
36 replies
CC#
Created by MechWarrior99 on 1/21/2024 in #help
How to safely access parameters from Task (Porting from Unity IJob)
TIL about long running.
36 replies
CC#
Created by MechWarrior99 on 1/21/2024 in #help
How to safely access parameters from Task (Porting from Unity IJob)
You might be missing a bit of the context, OP's question is "I'm familiar with Unity's Job system, what's the idiomatic way to do the same in a plain C# app?"
36 replies
CC#
Created by MechWarrior99 on 1/21/2024 in #help
How to safely access parameters from Task (Porting from Unity IJob)
Not sure tbh, but if you are worrying about potential race conditions then records is the simplest way to ensure they can't happen (you would still need to deal with cancelling ongoing tasks though, using cancellation token), and the code probably looks pretty similar to how you write jobs but cleaner.
36 replies
CC#
Created by MechWarrior99 on 1/21/2024 in #help
How to safely access parameters from Task (Porting from Unity IJob)
Yep, helps make code very simple too.
public record User(string FirstName, string LastName);

public record ResultJob(User User, int Score)
{
public async Task<string> Generate()
{
return await Task.Run(() =>
{
return $"{User.FirstName} {User.LastName} got a score of {Score}!";
});
}
}
public record User(string FirstName, string LastName);

public record ResultJob(User User, int Score)
{
public async Task<string> Generate()
{
return await Task.Run(() =>
{
return $"{User.FirstName} {User.LastName} got a score of {Score}!";
});
}
}
36 replies