https://github.com/prabirshrestha/facebook.extensions.task
C# v5 async extensions for Facebook C# SDK
https://github.com/prabirshrestha/facebook.extensions.task
Last synced: about 2 months ago
JSON representation
C# v5 async extensions for Facebook C# SDK
- Host: GitHub
- URL: https://github.com/prabirshrestha/facebook.extensions.task
- Owner: prabirshrestha
- License: other
- Created: 2011-05-09T17:06:00.000Z (about 14 years ago)
- Default Branch: master
- Last Pushed: 2023-12-15T20:20:52.000Z (over 1 year ago)
- Last Synced: 2025-03-29T09:11:33.413Z (3 months ago)
- Language: C#
- Homepage:
- Size: 1.41 MB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
**Facebook.Extensions.Tasks is no longer under development. These XTaskAsync() methods are now part of
the core Facebook C# SDK starting from v5.3**# Facebook.Extensions.Tasks
## Overview
This library takes the asynchorous programming with [Facebook C# SDK](http://facebooksdk.codeplex.com)
to the next level by adding extension methods to FacebookClient and FacebookOAuthClient which returns
Task<object>## Requirements
* [Microsoft Visual Studio Async CTP (SP1 Refresh)](http://msdn.microsoft.com/en-us/vstudio/async.aspx)
* .NET 4.0 or Silverlight 4 or Windows Phone 7 (.NET 3.5 is not supported)## Getting Started
Reference Facebook.Extensions.Tasks.dll which adds extension methods to FacebookClient and FacebookOAuthClient.
To prevent conflicts from existing async methods, these extension methods start with HttpMethod type and
ends with **TaskAsync( ... )**. Even though the dll name is "Facebook.Extensions.Tasks.dll" these extension
methods are under the "Facebook" namespace.Extension methods available for FacebookClient:
GetTaskAsync( ... )
PostTaskAsync( ... )
DeleteTaskAsync( ... )Extension methods available for FacebookOAuthClient:
GetApplicationAccessTokenTaskAsync( ... )
ExchangeCodeForAccessTokenTaskAsync( ... )## Samples
Full samples can be found under the "samples" folder in the source code.### Using with Task Parallel Library (TPL)
private static void ExecuteAsyncMethod()
{
var fb = new FacebookClient();
var task = fb.GetTaskAsync("/4");task.ContinueWith(
t =>
{
if (t.Exception == null)
{
dynamic result = t.Result;
Console.WriteLine("Name: {0}", result.name);
}
else
{
Console.WriteLine("error occurred");
}
});
}Note: If you are running the above code under .NET 4.0, you don't need to reference the Async libraries
as Task Parallel Library (TPL) comes bundled with .NET 4.0. For Silverlight and Windows Phone 7 Async libraries
(AsyncCtpLibrary\_Silverlight.dll or AsyncCtpLibrary\_Phone.dll) must be referenced as TPL is not present.### Using with async and await
private async static void ExecuteAsyncMethod()
{
var fb = new FacebookClient();try
{
dynamic result = await fb.GetTaskAsync("/4");Console.WriteLine("Name: {0}", result.name);
}
catch (FacebookApiException ex)
{
Console.WriteLine(ex.Message);
}
}Note: Reference the appropriate Async libraries (AsyncCtpLibrary.dll or AsyncCtpLibrary\_Silverlight.dll or
AsyncCtpLibrary\_Phone.dll). You need to reference AsyncCtpLibrary.dll for .NET 4.0 also in this case unlike
the example with TPL.## License
Facebook.Extensions.Tasks is intended to be used in both open-source and commercial environments.
It is licensed under Microsoft Public License (Ms-PL).