-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add sources of Microsoft.Bcl and Microsoft.Bcl.Aync NuGet packages
- Loading branch information
1 parent
e458f8d
commit 6952d2c
Showing
118 changed files
with
26,900 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
465 changes: 465 additions & 0 deletions
465
...l.Async/Microsoft.Threading.Tasks.Extensions.Desktop/AsyncPlatformExtensions.WebClient.cs
Large diffs are not rendered by default.
Oops, something went wrong.
693 changes: 693 additions & 0 deletions
693
Microsoft.Bcl.Async/Microsoft.Threading.Tasks.Extensions.Desktop/AsyncPlatformExtensions.cs
Large diffs are not rendered by default.
Oops, something went wrong.
92 changes: 92 additions & 0 deletions
92
...ft.Threading.Tasks.Extensions.Desktop/Microsoft.Threading.Tasks.Extensions.Desktop.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{9D4342DE-EF5A-4ACF-8AFC-0C777D23577B}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>System</RootNamespace> | ||
<AssemblyName>Microsoft.Threading.Tasks.Extensions.Desktop</AssemblyName> | ||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<SccProjectName>SAK</SccProjectName> | ||
<SccLocalPath>SAK</SccLocalPath> | ||
<SccAuxPath>SAK</SccAuxPath> | ||
<SccProvider>SAK</SccProvider> | ||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> | ||
<RestorePackages>true</RestorePackages> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<DocumentationFile>bin\Debug\Microsoft.Threading.Tasks.Extensions.Desktop.xml</DocumentationFile> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<DocumentationFile>bin\Release\Microsoft.Threading.Tasks.Extensions.Desktop.xml</DocumentationFile> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<SignAssembly>true</SignAssembly> | ||
<ExternallyShipping>true</ExternallyShipping> | ||
<AssemblyOriginatorKeyFile>..\CodePlexKey.snk</AssemblyOriginatorKeyFile> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Runtime"> | ||
<HintPath>..\..\packages\Microsoft.Bcl.1.0.19\lib\net40\System.Runtime.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System.ServiceModel" /> | ||
<Reference Include="System.ServiceModel.Channels" /> | ||
<Reference Include="System.ServiceModel.Discovery" /> | ||
<Reference Include="System.Threading.Tasks"> | ||
<HintPath>..\..\packages\Microsoft.Bcl.1.0.19\lib\net40\System.Threading.Tasks.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Xml" /> | ||
<Reference Include="WindowsBase" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="..\Microsoft.Threading.Tasks\Threading\Tasks\TaskServices.cs"> | ||
<Link>Threading\Tasks\TaskServices.cs</Link> | ||
</Compile> | ||
<Compile Include="AsyncPlatformExtensions.WebClient.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="Net\DnsEx.cs" /> | ||
<Compile Include="AsyncPlatformExtensions.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="app.config" /> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<Import Project="..\..\packages\Microsoft.Bcl.Build.1.0.19\build\Microsoft.Bcl.Build.targets" Condition="Exists('..\..\packages\Microsoft.Bcl.Build.1.0.19\build\Microsoft.Bcl.Build.targets')" /> | ||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> | ||
<PropertyGroup> | ||
<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.19\build\Microsoft.Bcl.Build.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Bcl.Build.1.0.19\build\Microsoft.Bcl.Build.targets'))" /> | ||
</Target> | ||
<!-- 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"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
10 changes: 10 additions & 0 deletions
10
...ading.Tasks.Extensions.Desktop/Microsoft.Threading.Tasks.Extensions.Desktop.csproj.vspscc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
"" | ||
{ | ||
"FILE_VERSION" = "9237" | ||
"ENLISTMENT_CHOICE" = "NEVER" | ||
"PROJECT_FILE_RELATIVE_PATH" = "" | ||
"NUMBER_OF_EXCLUDED_FILES" = "0" | ||
"ORIGINAL_PROJECT_FILE_PATH" = "" | ||
"NUMBER_OF_NESTED_PROJECTS" = "0" | ||
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" | ||
} |
33 changes: 33 additions & 0 deletions
33
Microsoft.Bcl.Async/Microsoft.Threading.Tasks.Extensions.Desktop/Net/DnsEx.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace System.Net | ||
{ | ||
/// <summary>Provides asynchronous wrappers for the <see cref="Dns"/> class.</summary> | ||
public static class DnsEx | ||
{ | ||
/// <summary>Asynchronously returns the Internet Protocol (IP) addresses for the specified host.</summary> | ||
/// <param name="hostNameOrAddress">The host name or IP address to resolve.</param> | ||
/// <returns>An array of type System.Net.IPAddress that holds the IP addresses for the host specified.</returns> | ||
public static Task<IPAddress[]> GetHostAddressesAsync(string hostNameOrAddress) | ||
{ | ||
return Task<IPAddress[]>.Factory.FromAsync(Dns.BeginGetHostAddresses, Dns.EndGetHostAddresses, hostNameOrAddress, null); | ||
} | ||
|
||
/// <summary>Asynchronously resolves an IP address to an System.Net.IPHostEntry instance.</summary> | ||
/// <param name="address">The IP address to resolve.</param> | ||
/// <returns>An System.Net.IPHostEntry instance that contains address information about the host.</returns> | ||
public static Task<IPHostEntry> GetHostEntryAsync(IPAddress address) | ||
{ | ||
return Task<IPHostEntry>.Factory.FromAsync(Dns.BeginGetHostEntry, Dns.EndGetHostEntry, address, null); | ||
} | ||
|
||
/// <summary>Asynchronously resolves an IP address to an System.Net.IPHostEntry instance.</summary> | ||
/// <param name="hostNameOrAddress">The host name or IP address to resolve.</param> | ||
/// <returns>An System.Net.IPHostEntry instance that contains address information about the host.</returns> | ||
public static Task<IPHostEntry> GetHostEntryAsync(string hostNameOrAddress) | ||
{ | ||
return Task<IPHostEntry>.Factory.FromAsync(Dns.BeginGetHostEntry, Dns.EndGetHostEntry, hostNameOrAddress, null); | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
Microsoft.Bcl.Async/Microsoft.Threading.Tasks.Extensions.Desktop/Properties/AssemblyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//-------------------------------------------------------------------------- | ||
// | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// | ||
//-------------------------------------------------------------------------- | ||
using System.Resources; | ||
using System.Reflection; | ||
using System.Runtime.InteropServices; | ||
using System.Security; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("Microsoft.Threading.Tasks.Extensions.Desktop")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyProduct("Microsoft.Threading.Tasks.Extensions.Desktop")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
[assembly: NeutralResourcesLanguage("en")] |
2 changes: 2 additions & 0 deletions
2
Microsoft.Bcl.Async/Microsoft.Threading.Tasks.Extensions.Desktop/app.config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration /> |
5 changes: 5 additions & 0 deletions
5
Microsoft.Bcl.Async/Microsoft.Threading.Tasks.Extensions.Desktop/packages.config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="Microsoft.Bcl" version="1.0.19" targetFramework="net40" /> | ||
<package id="Microsoft.Bcl.Build" version="1.0.19" targetFramework="net40" /> | ||
</packages> |
101 changes: 101 additions & 0 deletions
101
...rosoft.Threading.Tasks.Extensions.Phone/Microsoft.Threading.Tasks.Extensions.Phone.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProductVersion>10.0.20506</ProductVersion> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
<ProjectGuid>{AECCDA63-2C7E-4F94-B609-BA552C619EB3}</ProjectGuid> | ||
<ProjectTypeGuids>{C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>Microsoft.Threading.Tasks.Phone</RootNamespace> | ||
<AssemblyName>Microsoft.Threading.Tasks.Extensions.Phone</AssemblyName> | ||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> | ||
<SilverlightVersion>$(TargetFrameworkVersion)</SilverlightVersion> | ||
<TargetFrameworkProfile>WindowsPhone71</TargetFrameworkProfile> | ||
<TargetFrameworkIdentifier>Silverlight</TargetFrameworkIdentifier> | ||
<SilverlightApplication>false</SilverlightApplication> | ||
<ValidateXaml>false</ValidateXaml> | ||
<ThrowErrorsInValidation>true</ThrowErrorsInValidation> | ||
<SccProjectName>SAK</SccProjectName> | ||
<SccLocalPath>SAK</SccLocalPath> | ||
<SccAuxPath>SAK</SccAuxPath> | ||
<SccProvider>SAK</SccProvider> | ||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> | ||
<RestorePackages>true</RestorePackages> | ||
<FixedVersion>true</FixedVersion> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>Bin\Debug</OutputPath> | ||
<DefineConstants>TRACE;DEBUG;SILVERLIGHT;WINDOWS_PHONE</DefineConstants> | ||
<NoStdLib>true</NoStdLib> | ||
<NoConfig>true</NoConfig> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<DocumentationFile>Bin\Debug\Microsoft.Threading.Tasks.Extensions.Phone.xml</DocumentationFile> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>Bin\Release</OutputPath> | ||
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants> | ||
<NoStdLib>true</NoStdLib> | ||
<NoConfig>true</NoConfig> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<DocumentationFile>Bin\Release\Microsoft.Threading.Tasks.Extensions.Phone.xml</DocumentationFile> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<SignAssembly>true</SignAssembly> | ||
<ExternallyShipping>true</ExternallyShipping> | ||
<AssemblyOriginatorKeyFile>..\CodePlexKey.snk</AssemblyOriginatorKeyFile> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Runtime"> | ||
<HintPath>..\..\packages\Microsoft.Bcl.1.0.19\lib\sl4-windowsphone71\System.Runtime.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System.Threading.Tasks"> | ||
<HintPath>..\..\packages\Microsoft.Bcl.1.0.19\lib\sl4-windowsphone71\System.Threading.Tasks.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System.Windows" /> | ||
<Reference Include="System.Net" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="..\Microsoft.Threading.Tasks.Extensions.Desktop\AsyncPlatformExtensions.WebClient.cs"> | ||
<Link>AsyncPlatformExtensions.WebClient.cs</Link> | ||
</Compile> | ||
<Compile Include="..\Microsoft.Threading.Tasks.Extensions.Silverlight\AsyncPlatformExtensions.Dispatcher.cs"> | ||
<Link>AsyncPlatformExtensions.Dispatcher.cs</Link> | ||
</Compile> | ||
<Compile Include="..\Microsoft.Threading.Tasks\Threading\Tasks\TaskServices.cs"> | ||
<Link>Threading\Tasks\TaskServices.cs</Link> | ||
</Compile> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="app.config" /> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.$(TargetFrameworkProfile).Overrides.targets" /> | ||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.CSharp.targets" /> | ||
<ProjectExtensions /> | ||
<Import Project="..\..\packages\Microsoft.Bcl.Build.1.0.19\build\Microsoft.Bcl.Build.targets" Condition="Exists('..\..\packages\Microsoft.Bcl.Build.1.0.19\build\Microsoft.Bcl.Build.targets')" /> | ||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> | ||
<PropertyGroup> | ||
<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.19\build\Microsoft.Bcl.Build.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Bcl.Build.1.0.19\build\Microsoft.Bcl.Build.targets'))" /> | ||
</Target> | ||
<!-- 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"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
10 changes: 10 additions & 0 deletions
10
...Threading.Tasks.Extensions.Phone/Microsoft.Threading.Tasks.Extensions.Phone.csproj.vspscc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
"" | ||
{ | ||
"FILE_VERSION" = "9237" | ||
"ENLISTMENT_CHOICE" = "NEVER" | ||
"PROJECT_FILE_RELATIVE_PATH" = "" | ||
"NUMBER_OF_EXCLUDED_FILES" = "0" | ||
"ORIGINAL_PROJECT_FILE_PATH" = "" | ||
"NUMBER_OF_NESTED_PROJECTS" = "0" | ||
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" | ||
} |
19 changes: 19 additions & 0 deletions
19
Microsoft.Bcl.Async/Microsoft.Threading.Tasks.Extensions.Phone/Properties/AssemblyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
//-------------------------------------------------------------------------- | ||
// | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// | ||
//-------------------------------------------------------------------------- | ||
using System.Resources; | ||
using System.Reflection; | ||
using System.Runtime.InteropServices; | ||
using System.Security; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("Microsoft.Threading.Tasks.Extensions.Phone")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyProduct("Microsoft.Threading.Tasks.Extensions.Phone")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] |
2 changes: 2 additions & 0 deletions
2
Microsoft.Bcl.Async/Microsoft.Threading.Tasks.Extensions.Phone/app.config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration /> |
5 changes: 5 additions & 0 deletions
5
Microsoft.Bcl.Async/Microsoft.Threading.Tasks.Extensions.Phone/packages.config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="Microsoft.Bcl" version="1.0.19" targetFramework="wp71" /> | ||
<package id="Microsoft.Bcl.Build" version="1.0.19" targetFramework="wp71" /> | ||
</packages> |
63 changes: 63 additions & 0 deletions
63
...nc/Microsoft.Threading.Tasks.Extensions.Silverlight/AsyncPlatformExtensions.Dispatcher.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using System; | ||
using System.Net; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
|
||
/// <summary> | ||
/// Provides asynchronous wrappers for .NET Framework operations. | ||
/// </summary> | ||
public static partial class AsyncPlatformExtensions | ||
{ | ||
/// <summary>Asynchronously invokes an Action on the Dispatcher.</summary> | ||
/// <param name="dispatcher">The Dispatcher.</param> | ||
/// <param name="action">The action to invoke.</param> | ||
/// <returns>A Task that represents the execution of the action.</returns> | ||
public static Task InvokeAsync(this System.Windows.Threading.Dispatcher dispatcher, Action action) | ||
{ | ||
if (dispatcher == null) throw new ArgumentNullException("dispatcher"); | ||
if (action == null) throw new ArgumentNullException("action"); | ||
|
||
var tcs = new TaskCompletionSource<VoidTaskResult>(); | ||
dispatcher.BeginInvoke(new Action(() => | ||
{ | ||
try | ||
{ | ||
action(); | ||
tcs.TrySetResult(default(VoidTaskResult)); | ||
} | ||
catch (Exception exc) | ||
{ | ||
tcs.TrySetException(exc); | ||
} | ||
})); | ||
return tcs.Task; | ||
} | ||
|
||
/// <summary>Asynchronously invokes an Action on the Dispatcher.</summary> | ||
/// <param name="dispatcher">The Dispatcher.</param> | ||
/// <param name="function">The function to invoke.</param> | ||
/// <returns>A Task that represents the execution of the function.</returns> | ||
public static Task<TResult> InvokeAsync<TResult>(this System.Windows.Threading.Dispatcher dispatcher, Func<TResult> function) | ||
{ | ||
if (dispatcher == null) throw new ArgumentNullException("dispatcher"); | ||
if (function == null) throw new ArgumentNullException("function"); | ||
|
||
var tcs = new TaskCompletionSource<TResult>(); | ||
dispatcher.BeginInvoke(new Action(() => | ||
{ | ||
try | ||
{ | ||
var result = function(); | ||
tcs.TrySetResult(result); | ||
} | ||
catch (Exception exc) | ||
{ | ||
tcs.TrySetException(exc); | ||
} | ||
})); | ||
return tcs.Task; | ||
} | ||
} | ||
|
||
/// <summary>Used with Task(of void)</summary> | ||
internal struct VoidTaskResult { } |
Oops, something went wrong.