本文整理汇总了C#中System.Threading.Tasks.System.Threading.Tasks.TaskCompletionSource.TrySetException方法的典型用法代码示例。如果您正苦于以下问题:C# System.Threading.Tasks.TaskCompletionSource.TrySetException方法的具体用法?C# System.Threading.Tasks.TaskCompletionSource.TrySetException怎么用?C# System.Threading.Tasks.TaskCompletionSource.TrySetException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Threading.Tasks.System.Threading.Tasks.TaskCompletionSource
的用法示例。
在下文中一共展示了System.Threading.Tasks.TaskCompletionSource.TrySetException方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetReceiptsForUserAsync
/// <summary>
/// Finds the receipt list based on the FromDateTime parameter for the currently logged in user.
/// </summary>
/// <param name="fromDateTime">The starting date and time to get receipts from, leave this blank to get all the receipts.</param>
/// <returns>A Task<IEnumerable<Receipt> >that can be used to monitor progress on this call.</returns>
public static System.Threading.Tasks.Task<IEnumerable<Receipt>> GetReceiptsForUserAsync(this Buddy.Commerce commerce, System.Nullable<System.DateTime> fromDateTime = null)
{
var tcs = new System.Threading.Tasks.TaskCompletionSource<IEnumerable<Receipt>>();
commerce.GetReceiptsForUserInternal(fromDateTime, (bcr) =>
{
if (bcr.Error != BuddyServiceClient.BuddyError.None)
{
tcs.TrySetException(new BuddyServiceException(bcr.Error));
}
else
{
tcs.TrySetResult(bcr.Result);
}
});
return tcs.Task;
}
示例2: GetSoundAsync
/// <summary>
/// Retrieves a sound from the Buddy sound library, and returns a Stream. Your application should perisist this stream locally in a location such as IsolatedStorage.
/// </summary>
/// <param name="soundName">The name of the sound file. See the Buddy Developer Portal "Sounds" page to find sounds and get their names.</param>
/// <param name="quality">The quality level of the file to retrieve.</param>
public Task<Stream> GetSoundAsync(string soundName, Buddy.Sounds.SoundQuality quality)
{
var tcs = new System.Threading.Tasks.TaskCompletionSource<Stream>();
this.GetSoundInternal(soundName, quality, (bcr) =>
{
if (bcr.Error != BuddyServiceClient.BuddyError.None)
{
tcs.TrySetException(new BuddyServiceException(bcr.Error));
}
else
{
tcs.TrySetResult(bcr.Result);
}
});
return tcs.Task;
}
示例3: GetReceiptForUserAndTransactionIDAsync
/// <summary>
/// Finds the receipt associated with the specified CustomTransactionID for the currently logged in user.
/// </summary>
/// <param name="customTransactionID">The CustomTransactionID of the transaction. For Facebook payments this is the OrderID of the transaction.</param>
/// <returns>A Task<IEnumerable<Receipt> >that can be used to monitor progress on this call.</returns>
public static System.Threading.Tasks.Task<IEnumerable<Receipt>> GetReceiptForUserAndTransactionIDAsync(this Buddy.Commerce commerce, string customTransactionID)
{
var tcs = new System.Threading.Tasks.TaskCompletionSource<IEnumerable<Receipt>>();
commerce.GetReceiptForUserAndTransactionIDInternal(customTransactionID, (bcr) =>
{
if (bcr.Error != BuddyServiceClient.BuddyError.None)
{
tcs.TrySetException(new BuddyServiceException(bcr.Error));
}
else
{
tcs.TrySetResult(bcr.Result);
}
});
return tcs.Task;
}
示例4: GetCategoriesAsync
/// <summary>
/// Get all geo-location categories in Buddy.
/// </summary>
/// <returns>A Task<IDictionary<Int32,String> >that can be used to monitor progress on this call.</returns>
public static System.Threading.Tasks.Task<IDictionary<Int32, String>> GetCategoriesAsync(this Buddy.Places places)
{
var tcs = new System.Threading.Tasks.TaskCompletionSource<IDictionary<Int32, String>>();
places.GetCategoriesInternal((bcr) =>
{
if (bcr.Error != BuddyServiceClient.BuddyError.None)
{
tcs.TrySetException(new BuddyServiceException(bcr.Error));
}
else
{
tcs.TrySetResult(bcr.Result);
}
});
return tcs.Task;
}
示例5: GetAllAsync
/// <summary>
/// Get all GameState keys and values.
/// </summary>
/// <returns>A Task<IDictionary<String,GameState> >that can be used to monitor progress on this call.</returns>
public static System.Threading.Tasks.Task<IDictionary<String, GameState>> GetAllAsync(this Buddy.GameStates gameStates)
{
var tcs = new System.Threading.Tasks.TaskCompletionSource<IDictionary<String, GameState>>();
gameStates.GetAllInternal((bcr) =>
{
if (bcr.Error != BuddyServiceClient.BuddyError.None)
{
tcs.TrySetException(new BuddyServiceException(bcr.Error));
}
else
{
tcs.TrySetResult(bcr.Result);
}
});
return tcs.Task;
}
示例6: GetMyAsync
/// <summary>
/// Get all message groups that this user is part of.
/// </summary>
/// <returns>A Task<IEnumerable<MessageGroup> >that can be used to monitor progress on this call.</returns>
public static System.Threading.Tasks.Task<IEnumerable<MessageGroup>> GetMyAsync(this Buddy.MessageGroups messageGroups)
{
var tcs = new System.Threading.Tasks.TaskCompletionSource<IEnumerable<MessageGroup>>();
messageGroups.GetMyInternal((bcr) =>
{
if (bcr.Error != BuddyServiceClient.BuddyError.None)
{
tcs.TrySetException(new BuddyServiceException(bcr.Error));
}
else
{
tcs.TrySetResult(bcr.Result);
}
});
return tcs.Task;
}
示例7: GetSentAsync
/// <summary>
/// Get all sent message by the current user.
/// </summary>
/// <param name="afterDate">Optionally retreive only messages after a certain DateTime.</param>
/// <returns>A Task<IEnumerable<Message> >that can be used to monitor progress on this call.</returns>
public static System.Threading.Tasks.Task<IEnumerable<Message>> GetSentAsync(this Buddy.Messages messages, System.DateTime afterDate = default(DateTime))
{
var tcs = new System.Threading.Tasks.TaskCompletionSource<IEnumerable<Message>>();
messages.GetSentInternal(afterDate, (bcr) =>
{
if (bcr.Error != BuddyServiceClient.BuddyError.None)
{
tcs.TrySetException(new BuddyServiceException(bcr.Error));
}
else
{
tcs.TrySetResult(bcr.Result);
}
});
return tcs.Task;
}
示例8: CheckForValuesAsync
/// <summary>
/// Check for the existance of an identity value in the system. The search is perform for the entire app.
/// </summary>
/// <param name="values">The value to search for. This can either be a single value or a semi-colon separated list of values.</param>
/// <returns>A Task<IEnumerable<IdentityItemSearchResult> >that can be used to monitor progress on this call.</returns>
public static System.Threading.Tasks.Task<IEnumerable<IdentityItemSearchResult>> CheckForValuesAsync(this Buddy.Identity identity, string values)
{
var tcs = new System.Threading.Tasks.TaskCompletionSource<IEnumerable<IdentityItemSearchResult>>();
identity.CheckForValuesInternal(values, (bcr) =>
{
if (bcr.Error != BuddyServiceClient.BuddyError.None)
{
tcs.TrySetException(new BuddyServiceException(bcr.Error));
}
else
{
tcs.TrySetResult(bcr.Result);
}
});
return tcs.Task;
}
示例9: FindAsync
/// <summary>
/// Searches for statups by name within the distance of the specified location. Note: To search for all startups within the distance from the specified location, leave the SearchName parameter empty.
/// </summary>
/// <param name="searchDistanceInMeters">The radius of the startup search.</param>
/// <param name="latitude">The latitude where the search should start.</param>
/// <param name="longitude">The longitude where the search should start.</param>
/// <param name="numberOfResults">The number of search results to return.</param>
/// <param name="searchForName">Optional search string, for example: "Star*" to search for all startups that begin with the string "Star".</param>
/// <returns>A Task<IEnumerable<Startup> >that can be used to monitor progress on this call.</returns>
public static System.Threading.Tasks.Task<IEnumerable<Startup>> FindAsync(this Buddy.Startups startups, int searchDistanceInMeters, double latitude, double longitude, int numberOfResults=20, string searchForName = "")
{
var tcs = new System.Threading.Tasks.TaskCompletionSource<IEnumerable<Startup>>();
startups.FindInternal(searchDistanceInMeters, latitude, longitude, numberOfResults, searchForName, (bcr) =>
{
if (bcr.Error != BuddyServiceClient.BuddyError.None)
{
tcs.TrySetException(new BuddyServiceException(bcr.Error));
}
else
{
tcs.TrySetResult(bcr.Result);
}
});
return tcs.Task;
}
示例10: GetFreeStoreItemsAsync
/// <summary>
/// Returns information about all items in the store for the current application which are marked as free.
/// </summary>
/// <returns>A Task<IEnumerable<StoreItem> >that can be used to monitor progress on this call.</returns>
public static System.Threading.Tasks.Task<IEnumerable<StoreItem>> GetFreeStoreItemsAsync(this Buddy.Commerce commerce)
{
var tcs = new System.Threading.Tasks.TaskCompletionSource<IEnumerable<StoreItem>>();
commerce.GetFreeStoreItemsInternal((bcr) =>
{
if (bcr.Error != BuddyServiceClient.BuddyError.None)
{
tcs.TrySetException(new BuddyServiceException(bcr.Error));
}
else
{
tcs.TrySetResult(bcr.Result);
}
});
return tcs.Task;
}
示例11: AcceptAsync
/// <summary>
/// Accept a friend request from a user.
/// </summary>
/// <param name="user">The user to accept as friend. Can't be null and must be on the friend requests list.</param>
/// <param name="appTag">Tag this friend accept with a string.</param>
/// <returns>A Task<Boolean>that can be used to monitor progress on this call.</returns>
public static System.Threading.Tasks.Task<Boolean> AcceptAsync(this Buddy.FriendRequests friendRequests, Buddy.User user, string appTag = "")
{
var tcs = new System.Threading.Tasks.TaskCompletionSource<Boolean>();
friendRequests.AcceptInternal(user, appTag, (bcr) =>
{
if (bcr.Error != BuddyServiceClient.BuddyError.None)
{
tcs.TrySetException(new BuddyServiceException(bcr.Error));
}
else
{
tcs.TrySetResult(bcr.Result);
}
});
return tcs.Task;
}
示例12: CreateAsync
/// <summary>
/// Create a new virtual album. Note that this method internally does two web-service calls, and the IAsyncResult object
/// returned is only valid for the first one.
/// </summary>
/// <param name="name">The name of the new virtual album.</param>
/// <param name="appTag">An optional application tag for the album.</param>
/// <returns>A Task<VirtualAlbum>that can be used to monitor progress on this call.</returns>
public static System.Threading.Tasks.Task<VirtualAlbum> CreateAsync(this Buddy.VirtualAlbums virtualAlbums, string name, string appTag = "")
{
var tcs = new System.Threading.Tasks.TaskCompletionSource<VirtualAlbum>();
virtualAlbums.CreateInternal(name, appTag, (bcr) =>
{
if (bcr.Error != BuddyServiceClient.BuddyError.None)
{
tcs.TrySetException(new BuddyServiceException(bcr.Error));
}
else
{
tcs.TrySetResult(bcr.Result);
}
});
return tcs.Task;
}
示例13: GetAsync
/// <summary>
/// Get a virtual album by its globally unique identifier. All the album photos will be retreived as well. Note that this method internally does two web-service calls, and the IAsyncResult object
/// returned is only valid for the first one.
/// </summary>
/// <param name="albumId">The ID of the virtual album to retrieve.</param>
/// <returns>A Task<VirtualAlbum>that can be used to monitor progress on this call.</returns>
public static System.Threading.Tasks.Task<VirtualAlbum> GetAsync(this Buddy.VirtualAlbums virtualAlbums, int albumId)
{
var tcs = new System.Threading.Tasks.TaskCompletionSource<VirtualAlbum>();
virtualAlbums.GetInternal(albumId, (bcr) =>
{
if (bcr.Error != BuddyServiceClient.BuddyError.None)
{
tcs.TrySetException(new BuddyServiceException(bcr.Error));
}
else
{
tcs.TrySetResult(bcr.Result);
}
});
return tcs.Task;
}
示例14: UpdatePictureAsync
/// <summary>
/// Update virtual album picture comment or app.tag.
/// </summary>
/// <param name="picture">The picture to be updated, either PicturePublic or Picture works.</param>
/// <param name="newComment">The new comment to set for the picture.</param>
/// <param name="newAppTag">An optional new application tag for the picture.</param>
/// <returns>A Task<Boolean>that can be used to monitor progress on this call.</returns>
public static System.Threading.Tasks.Task<Boolean> UpdatePictureAsync(this Buddy.VirtualAlbum virtualAlbum, Buddy.PicturePublic picture, string newComment, string newAppTag = "")
{
var tcs = new System.Threading.Tasks.TaskCompletionSource<Boolean>();
virtualAlbum.UpdatePictureInternal(picture, newComment, newAppTag, (bcr) =>
{
if (bcr.Error != BuddyServiceClient.BuddyError.None)
{
tcs.TrySetException(new BuddyServiceException(bcr.Error));
}
else
{
tcs.TrySetResult(bcr.Result);
}
});
return tcs.Task;
}
示例15: AddPictureBatchAsync
/// <summary>
/// Add a list of pictures to this virtual album.
/// </summary>
/// <param name="pictures">The list of pictures to add to this photo album. Either PicturePublic or Picture works.</param>
/// <returns>A Task<Boolean>that can be used to monitor progress on this call.</returns>
public static System.Threading.Tasks.Task<Boolean> AddPictureBatchAsync(this Buddy.VirtualAlbum virtualAlbum, System.Collections.Generic.List<Buddy.PicturePublic> pictures)
{
var tcs = new System.Threading.Tasks.TaskCompletionSource<Boolean>();
virtualAlbum.AddPictureBatchInternal(pictures, (bcr) =>
{
if (bcr.Error != BuddyServiceClient.BuddyError.None)
{
tcs.TrySetException(new BuddyServiceException(bcr.Error));
}
else
{
tcs.TrySetResult(bcr.Result);
}
});
return tcs.Task;
}