当前位置: 首页>>代码示例>>C#>>正文


C# System.Threading.Tasks.TaskCompletionSource.TrySetResult方法代码示例

本文整理汇总了C#中System.Threading.Tasks.System.Threading.Tasks.TaskCompletionSource.TrySetResult方法的典型用法代码示例。如果您正苦于以下问题:C# System.Threading.Tasks.TaskCompletionSource.TrySetResult方法的具体用法?C# System.Threading.Tasks.TaskCompletionSource.TrySetResult怎么用?C# System.Threading.Tasks.TaskCompletionSource.TrySetResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Threading.Tasks.System.Threading.Tasks.TaskCompletionSource的用法示例。


在下文中一共展示了System.Threading.Tasks.TaskCompletionSource.TrySetResult方法的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&lt;IEnumerable&lt;Receipt&gt; &gt;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;
 }
开发者ID:rajeshwarn,项目名称:Buddy-DotNet-SDK,代码行数:21,代码来源:BuddyTaskWrappers.cs

示例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;
 }
开发者ID:rajeshwarn,项目名称:Buddy-DotNet-SDK,代码行数:21,代码来源:Sound.cs

示例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&lt;IEnumerable&lt;Receipt&gt; &gt;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;
 }
开发者ID:rajeshwarn,项目名称:Buddy-DotNet-SDK,代码行数:21,代码来源:BuddyTaskWrappers.cs

示例4: GetCategoriesAsync

 /// <summary>
 /// Get all geo-location categories in Buddy.
 /// </summary>
 /// <returns>A Task&lt;IDictionary&lt;Int32,String&gt; &gt;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;
 }
开发者ID:rajeshwarn,项目名称:Buddy-DotNet-SDK,代码行数:20,代码来源:BuddyTaskWrappers.cs

示例5: GetAllAsync

 /// <summary>
 /// Get all GameState keys and values.
 /// </summary>
 /// <returns>A Task&lt;IDictionary&lt;String,GameState&gt; &gt;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;
 }
开发者ID:rajeshwarn,项目名称:Buddy-DotNet-SDK,代码行数:20,代码来源:BuddyTaskWrappers.cs

示例6: GetMyAsync

 /// <summary>
 /// Get all message groups that this user is part of.
 /// </summary>
 /// <returns>A Task&lt;IEnumerable&lt;MessageGroup&gt; &gt;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;
 }
开发者ID:rajeshwarn,项目名称:Buddy-DotNet-SDK,代码行数:20,代码来源:BuddyTaskWrappers.cs

示例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&lt;IEnumerable&lt;Message&gt; &gt;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;
 }
开发者ID:rajeshwarn,项目名称:Buddy-DotNet-SDK,代码行数:21,代码来源:BuddyTaskWrappers.cs

示例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&lt;IEnumerable&lt;IdentityItemSearchResult&gt; &gt;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;
 }
开发者ID:rajeshwarn,项目名称:Buddy-DotNet-SDK,代码行数:21,代码来源:BuddyTaskWrappers.cs

示例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&lt;IEnumerable&lt;Startup&gt; &gt;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;
 }
开发者ID:rajeshwarn,项目名称:Buddy-DotNet-SDK,代码行数:25,代码来源:BuddyTaskWrappers.cs

示例10: GetFreeStoreItemsAsync

 /// <summary>
 /// Returns information about all items in the store for the current application which are marked as free.
 /// </summary>
 /// <returns>A Task&lt;IEnumerable&lt;StoreItem&gt; &gt;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;
 }
开发者ID:rajeshwarn,项目名称:Buddy-DotNet-SDK,代码行数:20,代码来源:BuddyTaskWrappers.cs

示例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&lt;Boolean&gt;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;
 }
开发者ID:rajeshwarn,项目名称:Buddy-DotNet-SDK,代码行数:22,代码来源:BuddyTaskWrappers.cs

示例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&lt;VirtualAlbum&gt;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;
 }
开发者ID:rajeshwarn,项目名称:Buddy-DotNet-SDK,代码行数:23,代码来源:BuddyTaskWrappers.cs

示例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&lt;VirtualAlbum&gt;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;
 }
开发者ID:rajeshwarn,项目名称:Buddy-DotNet-SDK,代码行数:22,代码来源:BuddyTaskWrappers.cs

示例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&lt;Boolean&gt;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;
 }
开发者ID:rajeshwarn,项目名称:Buddy-DotNet-SDK,代码行数:23,代码来源:BuddyTaskWrappers.cs

示例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&lt;Boolean&gt;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;
 }
开发者ID:rajeshwarn,项目名称:Buddy-DotNet-SDK,代码行数:21,代码来源:BuddyTaskWrappers.cs


注:本文中的System.Threading.Tasks.System.Threading.Tasks.TaskCompletionSource.TrySetResult方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。