codereview feedback.
Use Threading.Interlocked instead of direct assigned.
This commit is contained in:
Родитель
a1eca4831b
Коммит
cc10b42e05
|
@ -6,6 +6,7 @@ using System.Net.Http.Formatting.Parsers;
|
|||
using System.Net.Http.Internal;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
namespace System.Net.Http.Formatting
|
||||
{
|
||||
|
@ -101,7 +102,8 @@ namespace System.Net.Http.Formatting
|
|||
{
|
||||
// Initialize in a private collection to be thread-safe, and swap the finished object.
|
||||
// Ok to double initialize this.
|
||||
_nameValueCollection = HttpValueCollection.Build(this);
|
||||
NameValueCollection newCollection = HttpValueCollection.Build(this);
|
||||
Interlocked.Exchange(ref _nameValueCollection, newCollection);
|
||||
}
|
||||
return _nameValueCollection;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace System.Net.Http.Formatting
|
|||
{
|
||||
FormDataCollection form = new FormDataCollection(new Uri("http://foo.com"));
|
||||
|
||||
Assert.Equal(0, form.Count());
|
||||
Assert.Empty(form);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -45,7 +45,7 @@ namespace System.Net.Http.Formatting
|
|||
{
|
||||
FormDataCollection form = new FormDataCollection("");
|
||||
|
||||
Assert.Equal(0, form.Count());
|
||||
Assert.Empty(form);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -53,7 +53,7 @@ namespace System.Net.Http.Formatting
|
|||
{
|
||||
FormDataCollection form = new FormDataCollection((string) null);
|
||||
|
||||
Assert.Equal(0, form.Count());
|
||||
Assert.Empty(form);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
Загрузка…
Ссылка в новой задаче