UCMA 4.0 Async Extension Methods
Posted: October 26th, 2012 | Author: Michael | Filed under: UCMA 4.0 | Tags: async/await, asynchronous, Lync 2013, Lync Server 2013, multithreading, Task Parallel Library, TPL, UCMA 4.0 | 9 Comments »To make it easier for developers to use the new multithreading techniques from .NET 4.5 in UCMA 4.0 applications, I’ve put together a set of extension methods that turn pairs of Begin/End methods (such as BeginEstablish/EndEstablish) into Task objects that can be used with the awaitkeyword.
The collection of extension methods is available on CodePlex. Let me know if you have questions or suggestions.
Hi Michael, finally i found the others that researching in UCMA 4.0.
I need your help, any advice you give to me i will very appreciate it 🙂
I want to ask you about persistent chat sdk. I have problem with adding users as member to a chat room. I had a user that has creator role on a category. I succeeded on creating a new chat room. An exception is thrown stated “Unknown error occurred on the server” while i adding other users as a member to a chat room.
I had googled and binged the problem but no solution et all.
Please help me 🙁
Thank you before 🙂
Could you explain what your code does or post some of it? Is there any inner exception or are there any details in the exception?
[…] UCMA 4.0 Async Extension Methods […]
Thanks for the response. Finally i found the solutions and i posted here http://social.msdn.microsoft.com/Forums/en-US/lyncpersistentcssdk/thread/d63caa15-52ee-465f-9dc5-03d9c055202b.
Thank you for your response 🙂
by the way, I created the code for creating persistent chat room and want to add members dynamically. The problem is private chat room doesn’t allow me to add members dynamically.
Ran into a little problem using this code, the function “ApplicationEndpoint.EstablishAsync” does not call Begin/EndEstablish, it calls Begin/EndDrain. I have modified the function to call the correct methods, and changed it from Task to Task of SipResponse:
public static Task<SipResponseData> EstablishAsync(this ApplicationEndpoint endpoint)
{
return Task.Factory.FromAsync<SipResponseData>(
endpoint.BeginEstablish,
endpoint.EndEstablish, null);
}
Thanks for catching that. It’s actually supposed to be the DrainAsync method. EstablishAsync is in LocalEndpointMethods.cs.
I uploaded a fix.
Hey Michael,
I noticed that you had commented out the overload for
//public static Task ModifyConferenceConfigurationAsync(this ConferenceSession session,
// ConferenceAccessLevel accessLevel, LobbyBypass lobbyBypass,
// AutomaticLeaderAssignment automaticLeaderAssignment,
// ModifyConferenceConfigurationOptions options)
//{
// return Task.Factory.FromAsync(session.BeginModifyConferenceConfiguration,
// session.EndModifyConferenceConfiguration, accessLevel, lobbyBypass,
// automaticLeaderAssignment, options, null);
//}
This fails because FromAsync only had max 3 possible args in the generic overloads but you can still call more than 3 by using this notation
public static Task ModifyConferenceConfigurationAsync(this ConferenceSession session,
ConferenceAccessLevel accessLevel, LobbyBypass lobbyBypass,
AutomaticLeaderAssignment automaticLeaderAssignment,
ModifyConferenceConfigurationOptions options)
{
return Task.Factory.FromAsync(
(callback, state) => session.BeginModifyConferenceConfiguration(
accessLevel, lobbyBypass,
automaticLeaderAssignment, options, callback, state), session.EndModifyConferenceConfiguration, null);
}
Found a nice little article that explains it…
http://connect.microsoft.com/VisualStudio/feedback/details/734104/method-system-threading-tasks-task-factory-fromasync-has-insufficient-number-of-overloads
Thanks for the hard work. Cheers.
Shannon McCoy
[…] even better is that Michael Greenlee has put together a whole collection of extension methods for Lync which you can use. The most […]
[…] supports Tasks for asynchronous methods, although they’re not written into the UCMA SDK. Michael Greenlee has written a bunch of the more common Tasks as extension methods though and hosted them on […]