Skip to content

Commit de4ce32

Browse files
authored
Merge pull request #4212 from dotnet/publish-18568
Merge master into live
2 parents 38a2867 + 67f9991 commit de4ce32

File tree

3 files changed

+30
-21
lines changed

3 files changed

+30
-21
lines changed

samples/snippets/csharp/VS_Snippets_CLR_System/system.threading.semaphoreslim/cs/example.cs

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,27 @@ public static void Main()
1616
Console.WriteLine("{0} tasks can enter the semaphore.",
1717
semaphore.CurrentCount);
1818
Task[] tasks = new Task[5];
19-
19+
2020
// Create and start five numbered tasks.
21-
for(int i = 0; i <= 4; i++)
21+
for (int i = 0; i <= 4; i++)
2222
{
23-
tasks[i] = Task.Run( () => {
24-
// Each task begins by requesting the semaphore.
25-
Console.WriteLine("Task {0} begins and waits for the semaphore.",
26-
Task.CurrentId);
27-
semaphore.Wait();
23+
tasks[i] = Task.Run(() =>
24+
{
25+
// Each task begins by requesting the semaphore.
26+
Console.WriteLine("Task {0} begins and waits for the semaphore.",
27+
Task.CurrentId);
28+
semaphore.Wait();
2829

29-
Interlocked.Add(ref padding, 100);
30+
Interlocked.Add(ref padding, 100);
3031

31-
Console.WriteLine("Task {0} enters the semaphore.", Task.CurrentId);
32+
Console.WriteLine("Task {0} enters the semaphore.", Task.CurrentId);
3233

33-
// The task just sleeps for 1+ seconds.
34-
Thread.Sleep(1000 + padding);
34+
// The task just sleeps for 1+ seconds.
35+
Thread.Sleep(1000 + padding);
3536

36-
Console.WriteLine("Task {0} releases the semaphore; previous count: {1}.",
37-
Task.CurrentId, semaphore.Release()); } );
37+
Console.WriteLine("Task {0} releases the semaphore; previous count: {1}.",
38+
Task.CurrentId, semaphore.Release());
39+
});
3840
}
3941

4042
// Wait for half a second, to allow all the tasks to start and block.
@@ -47,7 +49,7 @@ public static void Main()
4749
semaphore.CurrentCount);
4850
// Main thread waits for the tasks to complete.
4951
Task.WaitAll(tasks);
50-
52+
5153
Console.WriteLine("Main thread exits.");
5254
}
5355
}

xml/System.Threading/CancellationTokenRegistration.xml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -450,12 +450,17 @@ The returned <xref:System.Threading.Tasks.ValueTask> completes once the associat
450450
<ReturnType>System.Threading.CancellationToken</ReturnType>
451451
</ReturnValue>
452452
<Docs>
453-
<summary>Gets the <see cref="T:System.Threading.CancellationToken" /> with which this registration is associated. If the
454-
registration isn't associated with a token (such as after the registration has been disposed),
455-
this will return a default token.</summary>
453+
<summary>Gets the <see cref="T:System.Threading.CancellationToken" /> with which this registration is associated.</summary>
456454
<value>The cancellation token with which this registration is associated, or a default token if the
457-
registration isn't associated with a token (such as after the registration has been disposed).</value>
458-
<remarks>To be added.</remarks>
455+
registration isn't associated with a token.</value>
456+
<remarks>
457+
<format type="text/markdown"><![CDATA[
458+
459+
If the <xref:System.Threading.CancellationTokenRegistration> was created by registering with a <xref:System.Threading.CancellationToken> that already
460+
had cancellation requested, the registration may not be associated with the token, in which case this property may return a default token.
461+
462+
]]></format>
463+
</remarks>
459464
</Docs>
460465
</Member>
461466
<Member MemberName="Unregister">

xml/System/String.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@
9898

9999
A string is a sequential collection of characters that is used to represent text. A <xref:System.String> object is a sequential collection of <xref:System.Char?displayProperty=nameWithType> objects that represent a string; a <xref:System.Char?displayProperty=nameWithType> object corresponds to a UTF-16 code unit. The value of the <xref:System.String> object is the content of the sequential collection of <xref:System.Char?displayProperty=nameWithType> objects, and that value is immutable (that is, it is read-only). For more information about the immutability of strings, see the [Immutability and the StringBuilder class](#Immutability) section later in this topic. The maximum size of a <xref:System.String> object in memory is 2GB, or about 1 billion characters.
100100

101+
For more information about Unicode, UTF-16, code units, code points, and the <xref:System.Char> and <xref:System.Text.Rune> types, see [Introduction to character encoding in .NET](/dotnet/standard/base-types/character-encoding-introduction).
102+
101103
In this section:
102104

103105
[Instantiate a String object](#Instantiation)\
@@ -214,15 +216,15 @@
214216
[!code-csharp-interactive[System.String.Class#5](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.String.Class/cs/index2.cs#5)]
215217
[!code-vb[System.String.Class#5](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.String.Class/vb/index2.vb#5)]
216218

217-
Consecutive index values might not correspond to consecutive Unicode characters, because a Unicode character might be encoded as more than one <xref:System.Char> object. In particular, a string may contain multi-character units of text that are formed by a base character followed by one or more combining characters or by surrogate pairs. To work with Unicode characters instead of <xref:System.Char> objects, use the <xref:System.Globalization.StringInfo?displayProperty=nameWithType> and <xref:System.Globalization.TextElementEnumerator> classes. The following example illustrates the difference between code that works with <xref:System.Char> objects and code that works with Unicode characters. It compares the number of characters or text elements in each word of a sentence. The string includes two sequences of a base character followed by a combining character.
219+
Consecutive index values might not correspond to consecutive Unicode characters, because a Unicode character might be encoded as more than one <xref:System.Char> object. In particular, a string may contain multi-character units of text that are formed by a base character followed by one or more combining characters or by surrogate pairs. To work with Unicode characters instead of <xref:System.Char> objects, use the <xref:System.Globalization.StringInfo?displayProperty=nameWithType> and <xref:System.Globalization.TextElementEnumerator> classes, or the <xref:System.String.EnumerateRunes%2A?displayProperty=nameWithType> method and the <xref:System.Text.Rune> type. The following example illustrates the difference between code that works with <xref:System.Char> objects and code that works with Unicode characters. It compares the number of characters or text elements in each word of a sentence. The string includes two sequences of a base character followed by a combining character.
218220

219221
[!code-cpp[System.String.Class#6](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.String.Class/cpp/string.index3.cpp#6)]
220222
[!code-csharp-interactive[System.String.Class#6](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.String.Class/cs/index3.cs#6)]
221223
[!code-vb[System.String.Class#6](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.String.Class/vb/index3.vb#6)]
222224

223225
This example works with text elements by using the <xref:System.Globalization.StringInfo.GetTextElementEnumerator%2A?displayProperty=nameWithType> method and the <xref:System.Globalization.TextElementEnumerator> class to enumerate all the text elements in a string. You can also retrieve an array that contains the starting index of each text element by calling the <xref:System.Globalization.StringInfo.ParseCombiningCharacters%2A?displayProperty=nameWithType> method.
224226

225-
For more information about working with units of text rather than individual <xref:System.Char> values, see the <xref:System.Globalization.StringInfo> class.
227+
For more information about working with units of text rather than individual <xref:System.Char> values, see [Introduction to character encoding in .NET](/dotnet/standard/base-types/character-encoding-introduction).
226228

227229
<a name="Nulls"></a>
228230
## Null strings and empty strings

0 commit comments

Comments
 (0)