Microsoft Lync has a rich set of .NET APIs which make it easy to extend the platform and integrate it with other applications. This blog helps explain how to use them.

UCMA 4.0 Async Extension Methods

Posted: October 26th, 2012 | Author: | Filed under: UCMA 4.0 | Tags: , , , , , , , | 7 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.


7 Comments on “UCMA 4.0 Async Extension Methods”

  1. 1 Raufan said at 2:49 pm on October 27th, 2012:

    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 :)

  2. 2 Michael said at 10:32 am on October 29th, 2012:

    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?

  3. 3 Lync MVP Article Roundup: October 2012 - NextHop - Site Home - TechNet Blogs said at 4:50 pm on October 30th, 2012:

    [...] UCMA 4.0 Async Extension Methods [...]

  4. 4 Raufan said at 2:24 pm on November 2nd, 2012:

    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.

  5. 5 duncan said at 6:02 am on December 12th, 2012:

    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);
    }

  6. 6 Michael said at 8:53 am on December 12th, 2012:

    Thanks for catching that. It’s actually supposed to be the DrainAsync method. EstablishAsync is in LocalEndpointMethods.cs.
    I uploaded a fix.

  7. 7 Shannon McCoy said at 8:18 am on December 21st, 2012:

    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


Leave a Reply

  • Note: Comment moderation is in use because of excessive spam. Your comment may not appear immediately.

  •