Skip to content

Commit 26f1447

Browse files
committed
main
1 parent 1115dd9 commit 26f1447

File tree

3 files changed

+29
-12
lines changed

3 files changed

+29
-12
lines changed

docs/.vitepress/config.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ const vitepressConfig = defineConfig({
1717
markdown: {
1818
lineNumbers: true,
1919
theme: {
20-
light: await themeService.getTheme('Eva Light'),
20+
light: await themeService.getTheme('JetBrains Rider New UI theme - Light'),
2121
// dark: await themeService.getTheme('Eva Dark'),
22-
dark: await themeService.getTheme('JetBrains Rider Dark Theme'),
22+
dark: await themeService.getTheme('JetBrains Rider New UI theme - Dark'),
2323
},
2424
codeTransformers: [transformerTwoslash()],
2525
},

docs/document/Modern CSharp/docs/Parallel Programming/Task/Create & Cancel.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,20 @@ To start a job there's multiple approaches to do the same:
2727
_ = Task.Factory.StartNew(() => Console.WriteLine("hello"));
2828
_ = Task.Run(() => Console.WriteLine("hello"));
2929

30-
31-
fooAsync(); // started automatically
32-
33-
var fooAsync = async () =>
30+
var fooAsync = async () =>
3431
{
3532
await Task.Run(() => Console.WriteLine("foo"));
36-
}
33+
};
34+
35+
fooAsync(); // started automatically
3736
```
3837

3938
> [!NOTE]
4039
> Continued tasks created by `ContinueWith` cannot `Start()`
4140
4241
### Create Task with Return
4342

44-
Generic tasks come into play when provided delegate would return a result.
43+
Generic tasks come into play when provided with delegate would return a result.
4544
The type parameter is exactly the type of return.
4645

4746
```cs
@@ -51,7 +50,8 @@ task.Start();
5150

5251
### Create with Argument
5352

54-
Both `TaskFactory` and `Task` supports an overload to accept **single argument** when the signature contains a parameter
53+
Both `TaskFactory` and `Task` supports an overload to accept **single argument** when the signature contains a parameter.
54+
5555
Since only single value is supported, you may need an abstraction when to pass multiple values
5656

5757
```cs
@@ -67,6 +67,9 @@ task.Start();
6767
> [!NOTE]
6868
> `Task.Run` does not support overloads accept an argument
6969
70+
> [!TIP]
71+
> One should prefer creating tasks supports arguments using `async` delegate unless you don't want it to begin immediately.
72+
7073
### Create from Async Delegate
7174

7275
`async` is a syntax sugar for creating task from a lambda or `async` method.
@@ -106,6 +109,7 @@ If one need to start a `async` delegate directly using `TaskFactory.StartNew`, `
106109
That is because, `async` delegate is a factory for dedicated task, so the result for starting the delegate directly would be a task created from the delegate instead of the expected result.
107110

108111
```cs
112+
// note: it's a wrapped task
109113
Task<Task<int>> t = Task.Factory.StartNew(async () =>
110114
{
111115
await Task.Delay(1000);
@@ -129,8 +133,9 @@ Task<int> t2 = await Task.Factory.StartNew(async () =>
129133
```
130134

131135
> [!TIP]
132-
> `Task.Run` has a implicit auto-unwrap for some of its overloads
136+
> `Task.Run` has a implicit auto-unwrap for some of its overloads, you may prefer this over `TaskFactory.StartNew` to start a simple task.
133137
>```cs
138+
>// The type is unwraped
134139
>Task<int> t = Task.Run(async () =>
135140
>{
136141
> await Task.Delay(1000);

docs/services/ThemeService.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ const themeInfos = {
3636
path: 'themes/JetBrains Rider Dark Theme-color-theme.json',
3737
branch: 'main',
3838
},
39+
'JetBrains Rider New UI theme - Dark': {
40+
repo: 'digimezzo/vscode-jetbrains-rider-new-ui-theme',
41+
path: 'themes/JetBrains Rider New UI-color-theme-dark.json',
42+
brach: 'main',
43+
},
44+
'JetBrains Rider New UI theme - Light': {
45+
repo: 'digimezzo/vscode-jetbrains-rider-new-ui-theme',
46+
path: 'themes/JetBrains Rider New UI-color-theme-light.json',
47+
brach: 'main',
48+
},
3949
} satisfies Record<string, RemoteThemeInfo>;
4050

4151
export type ThemeName = keyof typeof themeInfos;
@@ -73,9 +83,11 @@ class ThemeService implements IThemeService {
7383
async initializeRegistration(): Promise<void> {
7484
await Promise.all(
7585
(Object.entries(themeInfos) as [ThemeName, RemoteThemeInfo][]).map(async x => {
76-
const theme = await this.fetchThemeObject(x[1]);
86+
const [themeName, info] = x;
87+
const theme = await this.fetchThemeObject(info);
88+
if (!theme.name) theme.name = themeName; // in case the theme does not have a name to indentify itself
7789
await this.register(theme);
78-
console.log(`Textmate theme: \`${x[0]}\` has loaded.`);
90+
console.log(`Textmate theme: \`${themeName}\` has loaded.`);
7991
}),
8092
);
8193
}

0 commit comments

Comments
 (0)