Skip to content

Commit

Permalink
Remove ConfigureAwait(false)
Browse files Browse the repository at this point in the history
  • Loading branch information
bugthesystem committed Mar 15, 2015
1 parent 133d4b2 commit 03169de
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 19 deletions.
26 changes: 26 additions & 0 deletions FireSharp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FireSharp.Serialization.Jso
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FireSharp.Serialization.ServiceStack", "FireSharp.Serialization.ServiceStack\FireSharp.Serialization.ServiceStack.csproj", "{7B0E3BC1-4C1D-4748-B678-3197E8E194FC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FireSharp.Sample.Windows8App", "Samples\FireSharp.Sample.Windows8App\FireSharp.Sample.Windows8App.csproj", "{DEE14420-0A35-4E47-BB42-33C3EC691A8E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -94,6 +96,30 @@ Global
{7B0E3BC1-4C1D-4748-B678-3197E8E194FC}.Release|ARM.ActiveCfg = Release|Any CPU
{7B0E3BC1-4C1D-4748-B678-3197E8E194FC}.Release|x64.ActiveCfg = Release|Any CPU
{7B0E3BC1-4C1D-4748-B678-3197E8E194FC}.Release|x86.ActiveCfg = Release|Any CPU
{DEE14420-0A35-4E47-BB42-33C3EC691A8E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DEE14420-0A35-4E47-BB42-33C3EC691A8E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DEE14420-0A35-4E47-BB42-33C3EC691A8E}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{DEE14420-0A35-4E47-BB42-33C3EC691A8E}.Debug|ARM.ActiveCfg = Debug|ARM
{DEE14420-0A35-4E47-BB42-33C3EC691A8E}.Debug|ARM.Build.0 = Debug|ARM
{DEE14420-0A35-4E47-BB42-33C3EC691A8E}.Debug|ARM.Deploy.0 = Debug|ARM
{DEE14420-0A35-4E47-BB42-33C3EC691A8E}.Debug|x64.ActiveCfg = Debug|x64
{DEE14420-0A35-4E47-BB42-33C3EC691A8E}.Debug|x64.Build.0 = Debug|x64
{DEE14420-0A35-4E47-BB42-33C3EC691A8E}.Debug|x64.Deploy.0 = Debug|x64
{DEE14420-0A35-4E47-BB42-33C3EC691A8E}.Debug|x86.ActiveCfg = Debug|x86
{DEE14420-0A35-4E47-BB42-33C3EC691A8E}.Debug|x86.Build.0 = Debug|x86
{DEE14420-0A35-4E47-BB42-33C3EC691A8E}.Debug|x86.Deploy.0 = Debug|x86
{DEE14420-0A35-4E47-BB42-33C3EC691A8E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DEE14420-0A35-4E47-BB42-33C3EC691A8E}.Release|Any CPU.Build.0 = Release|Any CPU
{DEE14420-0A35-4E47-BB42-33C3EC691A8E}.Release|Any CPU.Deploy.0 = Release|Any CPU
{DEE14420-0A35-4E47-BB42-33C3EC691A8E}.Release|ARM.ActiveCfg = Release|ARM
{DEE14420-0A35-4E47-BB42-33C3EC691A8E}.Release|ARM.Build.0 = Release|ARM
{DEE14420-0A35-4E47-BB42-33C3EC691A8E}.Release|ARM.Deploy.0 = Release|ARM
{DEE14420-0A35-4E47-BB42-33C3EC691A8E}.Release|x64.ActiveCfg = Release|x64
{DEE14420-0A35-4E47-BB42-33C3EC691A8E}.Release|x64.Build.0 = Release|x64
{DEE14420-0A35-4E47-BB42-33C3EC691A8E}.Release|x64.Deploy.0 = Release|x64
{DEE14420-0A35-4E47-BB42-33C3EC691A8E}.Release|x86.ActiveCfg = Release|x86
{DEE14420-0A35-4E47-BB42-33C3EC691A8E}.Release|x86.Build.0 = Release|x86
{DEE14420-0A35-4E47-BB42-33C3EC691A8E}.Release|x86.Deploy.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
22 changes: 11 additions & 11 deletions FireSharp/FirebaseClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public FirebaseResponse Get(string path)
try
{
HttpResponseMessage response = _requestManager.Get(path);
string content = response.Content.ReadAsStringAsync().ConfigureAwait(false).GetAwaiter().GetResult();
string content = response.Content.ReadAsStringAsync().Result;
HandleIfErrorResponse(response.StatusCode, content);
return new FirebaseResponse(content, response.StatusCode);
}
Expand All @@ -58,7 +58,7 @@ public SetResponse Set<T>(string path, T data)
try
{
HttpResponseMessage response = _requestManager.Put(path, data);
string content = response.Content.ReadAsStringAsync().ConfigureAwait(false).GetAwaiter().GetResult();
string content = response.Content.ReadAsStringAsync().Result;
HandleIfErrorResponse(response.StatusCode, content);
return new SetResponse(content, response.StatusCode);
}
Expand All @@ -73,7 +73,7 @@ public PushResponse Push<T>(string path, T data)
try
{
HttpResponseMessage response = _requestManager.Post(path, data);
string content = response.Content.ReadAsStringAsync().ConfigureAwait(false).GetAwaiter().GetResult();
string content = response.Content.ReadAsStringAsync().Result;
HandleIfErrorResponse(response.StatusCode, content);
return new PushResponse(content, response.StatusCode);
}
Expand All @@ -88,7 +88,7 @@ public DeleteResponse Delete(string path)
try
{
HttpResponseMessage response = _requestManager.Delete(path);
string content = response.Content.ReadAsStringAsync().ConfigureAwait(false).GetAwaiter().GetResult();
string content = response.Content.ReadAsStringAsync().Result;
HandleIfErrorResponse(response.StatusCode, content);
return new DeleteResponse(content, response.StatusCode);
}
Expand All @@ -103,7 +103,7 @@ public FirebaseResponse Update<T>(string path, T data)
try
{
HttpResponseMessage response = _requestManager.Patch(path, data);
string content = response.Content.ReadAsStringAsync().ConfigureAwait(false).GetAwaiter().GetResult();
string content = response.Content.ReadAsStringAsync().Result;
HandleIfErrorResponse(response.StatusCode, content);
return new FirebaseResponse(content, response.StatusCode);
}
Expand All @@ -118,7 +118,7 @@ public async Task<FirebaseResponse> GetAsync(string path)
try
{
HttpResponseMessage response = await _requestManager.GetAsync(path);
string content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
string content = await response.Content.ReadAsStringAsync();
HandleIfErrorResponse(response.StatusCode, content);
return new FirebaseResponse(content, response.StatusCode);
}
Expand All @@ -133,7 +133,7 @@ public async Task<SetResponse> SetAsync<T>(string path, T data)
try
{
HttpResponseMessage response = await _requestManager.PutAsync(path, data);
string content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
string content = await response.Content.ReadAsStringAsync();
HandleIfErrorResponse(response.StatusCode, content);
return new SetResponse(content, response.StatusCode);
}
Expand All @@ -148,7 +148,7 @@ public async Task<PushResponse> PushAsync<T>(string path, T data)
try
{
HttpResponseMessage response = await _requestManager.PostAsync(path, data);
string content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
string content = await response.Content.ReadAsStringAsync();
HandleIfErrorResponse(response.StatusCode, content);
return new PushResponse(content, response.StatusCode);
}
Expand All @@ -163,7 +163,7 @@ public async Task<DeleteResponse> DeleteAsync(string path)
try
{
HttpResponseMessage response = await _requestManager.DeleteAsync(path);
string content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
string content = await response.Content.ReadAsStringAsync();
HandleIfErrorResponse(response.StatusCode, content);
return new DeleteResponse(content, response.StatusCode);
}
Expand All @@ -178,7 +178,7 @@ public async Task<FirebaseResponse> UpdateAsync<T>(string path, T data)
try
{
HttpResponseMessage response = await _requestManager.PatchAsync(path, data);
string content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
string content = await response.Content.ReadAsStringAsync();
HandleIfErrorResponse(response.StatusCode, content);
return new FirebaseResponse(content, response.StatusCode);
}
Expand All @@ -204,7 +204,7 @@ public async Task<EventRootResponse<T>> OnChangeGetAsync<T>(string path, ValueRo
public async Task<EventStreamResponse> OnAsync(string path, ValueAddedEventHandler added = null, ValueChangedEventHandler changed = null,
ValueRemovedEventHandler removed = null)
{
return new EventStreamResponse(await _requestManager.ListenAsync(path).ConfigureAwait(false), added, changed, removed);
return new EventStreamResponse(await _requestManager.ListenAsync(path), added, changed, removed);
}

private void HandleIfErrorResponse(HttpStatusCode statusCode, string content, Action<HttpStatusCode, string> errorHandler = null)
Expand Down
8 changes: 4 additions & 4 deletions FireSharp/RequestManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public async Task<HttpResponseMessage> PostAsync<T>(string path, T data)

public async Task<HttpResponseMessage> DeleteAsync(string path)
{
return await ProcessRequestAsync(HttpMethod.Delete, path, null, HttpCompletionOption.ResponseHeadersRead);
return await ProcessRequestAsync(HttpMethod.Delete, path, null);
}

public async Task<HttpResponseMessage> PatchAsync<T>(string path, T data)
Expand Down Expand Up @@ -118,7 +118,7 @@ public async Task<HttpResponseMessage> ListenAsync(string path)
var request = new HttpRequestMessage(HttpMethod.Get, uri);
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("text/event-stream"));

var response = await client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead).ConfigureAwait(false);
var response = await client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead);
response.EnsureSuccessStatusCode();

return response;
Expand All @@ -130,7 +130,7 @@ private async Task<HttpResponseMessage> ProcessRequestAsync(HttpMethod method, s
{
var request = PrepareRequest(method, path, payload);

return await GetClient().SendAsync(request, httpCompletionOption).ConfigureAwait(false);
return await GetClient().SendAsync(request, httpCompletionOption);
}
catch (Exception ex)
{
Expand All @@ -145,7 +145,7 @@ private HttpResponseMessage ProcessRequest(HttpMethod method, string path, objec
{
var request = PrepareRequest(method, path, payload);

return _client.SendAsync(request, httpCompletionOption).ConfigureAwait(false).GetAwaiter().GetResult();
return _client.SendAsync(request, httpCompletionOption).Result;
}
catch (Exception ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
<ProjectTypeGuids>{BC8A1FFA-BEE3-4634-8014-F334798102B3};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<PackageCertificateKeyFile>FireSharp.Test.Windows8App_TemporaryKey.pfx</PackageCertificateKeyFile>
<NuGetPackageImportStamp>75865d56</NuGetPackageImportStamp>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down Expand Up @@ -135,10 +137,6 @@
</Page>
</ItemGroup>
<ItemGroup>
<Reference Include="FireSharp, Version=2.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\FireSharp.2.0.1-beta3\lib\portable-net45+sl5+wp8+win8\FireSharp.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\win8\Microsoft.Threading.Tasks.dll</HintPath>
Expand All @@ -158,6 +156,12 @@
<HintPath>..\packages\Microsoft.Net.Http.2.2.29\lib\win8\System.Net.Http.Primitives.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\FireSharp\FireSharp.csproj">
<Project>{67b7ea6f-dc34-4f48-8331-58df137d78c9}</Project>
<Name>FireSharp</Name>
</ProjectReference>
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '12.0' ">
<VisualStudioVersion>12.0</VisualStudioVersion>
</PropertyGroup>
Expand All @@ -168,7 +172,9 @@
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets'))" />
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down

0 comments on commit 03169de

Please sign in to comment.